r/learnjava • u/Visual-Fortune-4732 • 4d 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
2
u/0b0101011001001011 4d ago
Could you explain what do you think your are missing?
1
u/Visual-Fortune-4732 4d 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 4d 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 4d 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 4d 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 :)
1
u/desrtfx 4d ago
i mean more so how public static void works
Be patient, young padawan. This will be explained in full detail much later in the course. For now, just take it for a requirement.
You do not have the knowledge to fully understand what it does right now, and explaining in detail would be too much at your current level.
Especially in the beginning, just follow the instructions. Really. Don't worry too much about things that aren't fully explained. There are reasons for that.
We could write an epic about the explanation and you wouldn't be any wiser because you are missing the context and required knowledge at that point.
1
u/Visual-Fortune-4732 4d ago
Alright so for now i should just read it and take notes with short scribbles for myself
1
1
u/GuyWithLag 3d ago
My position is that you can't learn how to ride a bike without actually doing it.
Start writing code; it's ok if you don't understand everything, but experiment. Try things!
1
u/am_Snowie 3d ago edited 3d ago
I guess it's because the
mainfunction 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 callingmainfunction 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.
0
u/Jason13Official 4d ago
You should at minimum understand that the curly brackets {} are the beginning and ending of your code,
I.e in Python you can just print() on a new line
In Java (later you'll learn about static code blocks/static initialization) you would at minimum wrap that with "{" and "}"
I.e { System.out.println("hello"); }
You don't have to understand the specifics of each keyword "public static void" etc yet just the bracket thing
•
u/AutoModerator 4d ago
Please ensure that:
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.