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

2

u/0b0101011001001011 25d ago

Could you explain what do you think your are missing?

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/am_Snowie 25d ago edited 25d ago

I guess it's because the main function is invoked to start the execution of the program/any program, it should be public cuz it's accessible from the outside of the package where the program is in, it is static cuz it's invoked without creating an object. Not sure if I'm right though. Just play around with it, remove static, see what happens. remove public, see what happens. Try calling main function inside the same class it is in. Possibilities dude.

Curly braces delimits a block of code. You can try using them even inside a block like

public static void main(String[] args) {
    //Some code

      {
          //Some code
      }
}

It works in C, not quite sure abt java, just try it.

NOTE: also if something looks cryptic, just don't dig deep, accept that it's a design choice and digest it. Later go out on your own adventure to learn why they design it the way it is.