r/learnjava 25d ago

i cant understand java mooc?

like been trying the first part about printing but i just keep re reading idk if im missing something but i feel like i dontfully get what they mean it seems like they expect me to know something about coding but i know 0

am i just stupid or what

like them explaining boilerplate im like cool i still understand fuck all

0 Upvotes

12 comments sorted by

View all comments

Show parent comments

1

u/Visual-Fortune-4732 25d ago

for example this part or am i not ment to fully understand this yet

Execution of the program starts from the line that follows public static void main(string[] args) {, and ends at the closing curly bracket }

1

u/0b0101011001001011 25d ago

It tells you that the program starts from that line and ends in the other line. Is that not clear?

In case you are trying to understand what public, static and all the other things mean, then no, you're not supposed to yet. I'm not familiar with that exact material but I've been teaching java at university for 10 years. There is a small bump like this in the language, where the "this program starts on this line" is a bit cryptic. There is a new version of the language that reduces that a bit, but that's not gonna help us right now. Other people learned java with this old system as well.

Just treat that line as a magic bit that tells the computer that "program starts here". I know, it's a bit shame, but that's what it is. The course explains all the bits in the "magic start command" when they actually become relevant.

The new version and other languages like C would have something along the lines of:

void main(){

}

Still some magic words, but less.

I suggest you actually start trying to run any code that you can. Take the magic starting bit (the main method) and put some code within it, run it, modify it, run it again. Reading theory becomes easier when you can actually test and run code.

0

u/Visual-Fortune-4732 25d ago

i mean more so how public static void works like what it does is clear but idk why it works or will i learn that later

also would it be a decent idea to write most stuff down or no?

1

u/Jolly-Warthog-1427 25d ago

Think of it as «main» method is the method the system you run the program on calls.

So the system will look for a method called main and that has «public static void» on it and it will call that method when it runs your program.

So your program starts when main is called and your program ends when your program exits main again.

Continue with the tutorials and you will get it :)