r/programming • • Feb 23 '12

Don't Distract New Programmers with OOP

http://prog21.dadgum.com/93.html
207 Upvotes

288 comments sorted by

View all comments

Show parent comments

3

u/Deepmist Feb 23 '12

Hah! I remember being so, so frustrated in school when my teacher's wouldn't/couldn't explain all the "boilerplate" code they wrapped around the things we actually learned about. I wanted to know the significance of every single character. It took me about a year to memorize "public static void main" because I was bad at memorizing and didn't understand what it actually said.

3

u/[deleted] Feb 24 '12

Worst part - if you omit public or static it will still compile succesfully. Try to run it and you'll get all sort of cryptic errors.

1

u/Falmarri Feb 24 '12

I've been programming in Java for 10 years and I still have to look up the exact syntax for main methods.

3

u/pingveno Feb 24 '12 edited Feb 24 '12

public: The method is not internal to the class. It must be available for general use.

static: It's a static method on the class that is only loosely associated with the class. Doesn't directly work with the class or an instance except in the way that any other code would interact. A side effect of Java's OMG EVERYTHING MUST BE PART OF A CLASS.

void: No status is returned, unlike in C.

main: Just like in many other languages.

String[]: The arguments that were passed into the program. Unlike C's argv in that its first element isn't the executable name.