@@beesetti.d.ssubhash5075 if a method in a class is static, you'd need to create an instance of the class "Class1 class = new class()" in order to call the method, however if isn't static, you wouldn't need to to create the "Class1 class = new class()". You can directly call the method by writing Class1.method
Yeah it's the other way around. If it's static, you can (and should) call it directly on the class without creating an object. But if it's not static, you have to create an object and call the method on the object.
The reason why i love this channel is the explanation is just like the way it's needed and basics are at-least a bit clearer than what we know already.
@@kebbil in any course you'll go over classes, methods and arguments, so you should be able to figure out what it does by yourself. Besides, they went over this in my course without even us asking
havent watched the video yet but: public - the accessor, means the method is accessible in other classes; static - the class doesnt need to be instantiated to be called; void - the return type, it does not return anything; main is of course the name and it takes in command line arguments represented by an array of strings called args
1. jre calls the public main() 2. static methods in a class can be called without creating an instance of that class. Just call MainMethodExplaination.main() 3. void because does not return anything. 4. String args[] => passing arguments as an input .
I just started my BA in IT but going towards the coding route with my degree and currently in my first intro to coding class at my university and I thank you for your explanations! This is all super helpful.
Watching your videos bring me the feeling that I could talk to you drinking a beer and learning a lot of coding stuff for HOURS. You're funny and smart, and know properly what you're saying. Amazing
Another clever idea: if it's an array of strings, you can also modify it to an array of integers! It works similarly! Thank you for this excential explanation!!
I would like a big o notation lesson on search algorithms! Please discuss the space and time complexities of various algorithms and their most suitable applications!
Hello I have search so many videos on public static void main. But this is the first one that is clearer. You made it lot easier. You have any courses I can take?
Thanks! There's one linked in the description if you're interested. You can see all the content that's included and watch a few lessons free before you buy anything.
Glad it helped! When you're first getting started it can be kind of overwhelming and confusing to understand everything that's going on with it, so "just put it in there" isn't terrible advice for your very first program. But after a while it's valuable to be clear why it's all there.
Imagine you’re baking a cake: So, public static void main(String[] args) means: public: Anyone can use this recipe. static: You don't need to make a whole cake to read the recipe. void: The recipe itself doesn't give you cake. main: This is the name of the recipe. (String[] args): This part is like optional ingredients that you might add to the recipe.
I always hate the "just do it this way" teaching method. You never really know how to work around problems, only a few steps and well.....not all problems fit within those steps. Thanks for the video series on Java, by far the best I've found on YT.
Starting with Java 21, the days when we have to stop enthusiastic beginners from asking questions about 'public static void main(String[] args)' because it's simply too advanced for a first lesson, are finally over. Nevertheless, great explanations, keep going!
Great video, when I was taking java at university I felt they had way too many analogies, that by the end of them I was just confused and bored, and didn't answer stuff like this fully glad to heard a nice clear explanation instead of something like "you'll learn that later"
Hello John, I really like the way you teach. Absolutely great!!! On similar lines to this video, students most of the time also think about the real stuff behind System.out.println(). Can you create a video explaining each part - What is System, out, println? Also the static nature of out and thus it can be used on top of the System class directly instead of an object. Cheers
The elephant in my text editor has been explained, thanks! I’ve watched a bunch of java youtubers, but you are indeed the most thorough with explaining java concepts!
Hey John, you are providing a great educational value. Your videos always help to clear my doubts and understand the basics of Java. Keep it up. Thanks a lot.
hahaha! I had a really good chuckle, those first 30 seconds. "Don't ask! shut up, no don't! stop. Just do it, put it in there!" I was on the receiving end of that. Art imitates life, right?
Thank you for sharing, I was hopping you can explain it better than others, can you try to explain it with example for a beginners that we can understand it easily.
Hi John !!! I have been following you and watching alllll of your Java tutorials all the time would love to meet one day if you are anywhere near east coast !! I realized in this video though you are very quiet 😊 are you trying to to not wake someone up at home ??!! 😛 you are great thank you so much for al the useful info ! I hope the best for you
Interestingly, the designers of Java could have opted to return an int from the main method (instead of void) to indicate to the OS the state the program completed in e.g. success, failure etc.. You can actually specify such an int when you call System.exit to exit the program.
This is a very fun and easy to understand explanation. I'm not even a java developer (learning c#) but I understood it perfectly. I've noticed java and c# share similar syntax tho.
"It's kind of like saying hey I'm a great program and the JRE goes 'great how can I run you'? and he's like you can't. Only I can run me." "and that's a pretty useless program". This statement while maybe not intended to be interpreted nor regarded in this way is full of wisdom not only in regards to coding but when applied to life in general, lol🤣. 10/10. Just wanted to point that out. Thank you for all the vids John, you're helping me a lot.
Do u have a video that teach about java command and show what the behind scene of the command working ? .and may be about maven and gradle that would be great too.
Hello, John! How does one delimit the arguments args[x], one from another? How does one count the arguments? I expect there is a method to do just that. Nice explanation. Many thanks.
That's actually the first thing any Java crash course tutorial should explain, but instead they just say: "That's the way it is". SMH... Anyways, amazing video as always. 👏👏👏👏
I'll see what I can do! Luckily in Java garbage collection is something you pretty much never have to think about, since it takes care of it by itself unlike some other languages.
I think that this style of explanation - starting from the absolute bottom first, explaining all this st*pid keywords (of this alien language ;) - is the best appraoch you can have. Even if it takes some minutes longer, it will clear out some questions that every newbie has at the beginning. [even better would be some history on WHY this or that keyword had to be invented...] Thanks man.
Thanks a lot John. Appreciate the clear explanation! :) qq - you said the JRE will access your mail method like className.main() so is it jre or jvm that accesses our main method ?
You can visualize it in terms of three circles JVM( Java Virtual Machine) I think being the largest and containing JRE (Java Runtime Environment) which contains the the program( .Class file) . JRE is basically needed when you execute a program (.class file) and JVM when programming the java file ( JVM in simple terms converts the java file you have written into ".class" File which the JRE understands). So JRE is the one that accesses the main method.
Finally, someone with the cojones to explain this thoroughly! Nice job. Incidentally, have you ever considered becoming a Dean at a community college in Greendale CO? :P
For whatever reason I have struggled with really understanding "static" and you just cleared it up for me. Thanks, John!
Can you please explain with an example.
😊
@@beesetti.d.ssubhash5075 if a method in a class is static, you'd need to create an instance of the class "Class1 class = new class()" in order to call the method, however if isn't static, you wouldn't need to to create the "Class1 class = new class()". You can directly call the method by writing Class1.method
does this make sense?
@@jumpz5561
Or is it the other way round
Yeah it's the other way around. If it's static, you can (and should) call it directly on the class without creating an object. But if it's not static, you have to create an object and call the method on the object.
the scenario at the beginning was LITERALLY MY EXPERIENCE. tysm
You seriously deserve more subscribers. You are an amazing teacher, thank you John
Yes, that's why I told all of my classmates about John. We call him "Java John"
The reason why i love this channel is the explanation is just like the way it's needed and basics are at-least a bit clearer than what we know already.
helloJohn, sometimes I’m having a language barriers but when you explain I don’t feel that. I appreciate it great explanation.
It feels good , when you already know all these stuff and still watching this complete video 🤗
0:23 no one quite says that. They just say they’ll discuss it later. Lol but you are such a good teacher. Happy I found you!
and never do
@@kebbil in any course you'll go over classes, methods and arguments, so you should be able to figure out what it does by yourself. Besides, they went over this in my course without even us asking
thats what your wife says the first time you are having sex with her
well ur lucky if they do.My teacher didnt say anything,she just said thats a default in java.So it really depends on the kinda teacher u hav
It's quite straightforward once you get into the language. Initially, they give a vague definition so you can go on with the learning.
You are so enthusiastic when you teach. thanks for the lesson,it was easy to understand
Very glad to hear that, thanks for watching!
havent watched the video yet but: public - the accessor, means the method is accessible in other classes; static - the class doesnt need to be instantiated to be called; void - the return type, it does not return anything; main is of course the name and it takes in command line arguments represented by an array of strings called args
1. jre calls the public main()
2. static methods in a class can be called without creating an instance of that class. Just call MainMethodExplaination.main()
3. void because does not return anything.
4. String args[] => passing arguments as an input .
Three years later, i've "super appreciated" your video ! Thx 🤩
man i just stumbled upon your channel and im simply blown away by the quality of your content, it's gold
Might be good to note that those main args are typically used for advanced configuration options.
I just started my BA in IT but going towards the coding route with my degree and currently in my first intro to coding class at my university and I thank you for your explanations! This is all super helpful.
Watching your videos bring me the feeling that I could talk to you drinking a beer and learning a lot of coding stuff for HOURS. You're funny and smart, and know properly what you're saying. Amazing
Thank you so much!
Thank you for explaining public static void main and how to use that args array!
Another clever idea: if it's an array of strings, you can also modify it to an array of integers! It works similarly!
Thank you for this excential explanation!!
Finally, a clear, succinct, and helpful explanation!
Glad it was helpful!
My mind always asks me 'why' and when I can't get the answers my learning shuts down, thank you for this explanation!
Neither college teachers nor the textbooks ever explained what args do. Thanks for the clear explanation.
Top 2 Teachers in You tube.
The Cherno, Coding with John
Thank you John!!
I would like a big o notation lesson on search algorithms! Please discuss the space and time complexities of various algorithms and their most suitable applications!
Hello
I have search so many videos on public static void main. But this is the first one that is clearer. You made it lot easier. You have any courses I can take?
Thanks! There's one linked in the description if you're interested. You can see all the content that's included and watch a few lessons free before you buy anything.
@@CodingWithJohn I already code but I get confused on how to start
Interesting, thx. Btw, the word “main” is inherited from C language. main function is entrance point in C.
the
int main{} thingy?
omg...bro is better teacher than all my professors combined lol GREAT VIDEO!
THANKS A LOT! People just saying "just copy this" was driving me nuts.
Glad it helped! When you're first getting started it can be kind of overwhelming and confusing to understand everything that's going on with it, so "just put it in there" isn't terrible advice for your very first program. But after a while it's valuable to be clear why it's all there.
Imagine you’re baking a cake:
So, public static void main(String[] args) means:
public: Anyone can use this recipe.
static: You don't need to make a whole cake to read the recipe.
void: The recipe itself doesn't give you cake.
main: This is the name of the recipe.
(String[] args): This part is like optional ingredients that you might add to the recipe.
thanks john im a 7th grader trying to learn java this video helped out a lot thanks
I don't wanna underrate any of your other videos but this one (especially the introduction) really got me insanely immersed
It would be awesome if you could do a video just on the static keyword. Why would you use it besides in the main method and stuff.
“Args” is actually the sound I make trying to understand computer language
this is my favorite channel for clearing up Java concepts, thank you so much John
I always hate the "just do it this way" teaching method. You never really know how to work around problems, only a few steps and well.....not all problems fit within those steps. Thanks for the video series on Java, by far the best I've found on YT.
This was very helpful....I just started learning Java last night (I was a JavaScript guy) and this really cleared things up! Gracias!!
I'm studying for my theory final in a couple days and you're helping me tremendously
The bottom line is use the "main " as it is... it was amazing.
Yep, just use it as it is. But it's good to know why it is how it is!
Starting with Java 21, the days when we have to stop enthusiastic beginners from asking questions about 'public static void main(String[] args)' because it's simply too advanced for a first lesson, are finally over. Nevertheless, great explanations, keep going!
Great video, when I was taking java at university I felt they had way too many analogies, that by the end of them I was just confused and bored, and didn't answer stuff like this fully
glad to heard a nice clear explanation instead of something like "you'll learn that later"
Hello John, I really like the way you teach. Absolutely great!!!
On similar lines to this video, students most of the time also think about the real stuff behind System.out.println(). Can you create a video explaining each part - What is System, out, println? Also the static nature of out and thus it can be used on top of the System class directly instead of an object.
Cheers
Extremely useful! Congratz John.
The elephant in my text editor has been explained, thanks! I’ve watched a bunch of java youtubers, but you are indeed the most thorough with explaining java concepts!
I started watching your videos yesterday and I am subscribed now, very interesting explanations!
If you could, please add to this about having multiple arguments rather than just one.
The story in the beginning is so accurate
bro this video made me subscribe without any hesitations ...... l like the way you started your video
Hey John, you are providing a great educational value. Your videos always help to clear my doubts and understand the basics of Java. Keep it up. Thanks a lot.
Yep.... that was my teacher, like:" no more questions" :-/
Thank you for this great video. :D
Wow, Never knew what it means. Super simple explaination
Thanks for this. Nicely done. One question I have is can you think of a realistic use case for assigning value to the String[] args array?
hahaha! I had a really good chuckle, those first 30 seconds.
"Don't ask! shut up, no don't! stop. Just do it, put it in there!"
I was on the receiving end of that. Art imitates life, right?
Thanks so much bro. This honestly helped so much. Walking away a little more confident 👍
yours the first channel i subscribed after watching many others.. you are just too good to be on you tube. I love your videos.
Java:
class MainClass {
public static void main (String [] args) {
System.out.println("Hello World");
}
}
Python:
print("hello world")
Man. I have to tell your channel to my classmates, coz I'm having trouble explaining Java to them.
Thank you for sharing, I was hopping you can explain it better than others, can you try to explain it with example for a beginners that we can understand it easily.
Hi John !!! I have been following you and watching alllll of your Java tutorials all the time would love to meet one day if you are anywhere near east coast !! I realized in this video though you are very quiet 😊 are you trying to to not wake someone up at home ??!! 😛 you are great thank you so much for al the useful info ! I hope the best for you
John you are absolutely legend
Thanks for the video! Great stuff man
Thank you a lot❤❤ you are really helpful and you are very understandable
After al those hours searching for explanations this is the only video I found helpful and entertaining!
Keep it up!
Thank you for this. I was always wondering what it all did and I could never geta good answer.
Interestingly, the designers of Java could have opted to return an int from the main method (instead of void) to indicate to the OS the state the program completed in e.g. success, failure etc.. You can actually specify such an int when you call System.exit to exit the program.
I was wondering about that. I've been learning a lot of C lately and having your main function return an exit code seems to be the standard there.
It does return a code based on the success in Intellij IDEA I haven't tried in other IDEs so idk about others
This is a very fun and easy to understand explanation. I'm not even a java developer (learning c#) but I understood it perfectly. I've noticed java and c# share similar syntax tho.
Haven't seen the video yet... But that's exactly what I asked yeaaars ago trying to do C#
I never progressed.
Could you please make a video explaining each part of System.out.println()? Thank you
It's a method called println(), which is part of the *out* field in the System class. "Out" in this case is an instance of PrintStream.
"It's kind of like saying hey I'm a great program and the JRE goes 'great how can I run you'? and he's like you can't. Only I can run me." "and that's a pretty useless program".
This statement while maybe not intended to be interpreted nor regarded in this way is full of wisdom not only in regards to coding but when applied to life in general, lol🤣. 10/10. Just wanted to point that out. Thank you for all the vids John, you're helping me a lot.
Philosophy with John
Hello, Sir! We'd all really appreciate if you break down SOLID on this channel, especially LSP🙏🙏🙏
Do u have a video that teach about java command and show what the behind scene of the command working ? .and may be about maven and gradle that would be great too.
A must like from me for all of your videos.
Great video! Though I've got one question left. How do I pass multiple arguments (so that the args array contains more than one string)?
Way to clearly explain things. Thank you. 👍
This was a video I was always looking for when I was a beginner, thanks 🙏
Your explanations are amazing. Keep up the good work. Wish you all the best ❤
Thank you. It is useful for interview
Hello, John!
How does one delimit the arguments args[x], one from another? How does one count the arguments? I expect there is a method to do just that.
Nice explanation. Many thanks.
Can you do a series on backtracking and dynamic programming
This was very helpful, thank you
That's actually the first thing any Java crash course tutorial should explain, but instead they just say: "That's the way it is". SMH... Anyways, amazing video as always. 👏👏👏👏
Great explanation sir
Great and simple video! Congrats and thanks
Definitely demystified a lot of things for me here! Super useful vid for me who is learning Java coming from python :-)
Mee too, coming to Java from Python. 😊
Initially, I would do a lot of comparison between the two.
English? Jre? Instance? Method? What is static like? Sits still? What if I wanted #s, not strings?
you really though he would explain every single part of OOP in Java in this video? it would take literally 4-5 hours
Perfect John, please upload design pattern serie in JAVA.
there's one more thing can you plz make a video on how memory management works like stack and heap and garbage collection.
I'll see what I can do! Luckily in Java garbage collection is something you pretty much never have to think about, since it takes care of it by itself unlike some other languages.
@@CodingWithJohn ok thnx. i like the way you teach
@@bhratchaudhary2249 I really appreciate the kind words!
Amazing explanation, thank u so much!
Most dramatic version of you in this video 😀
That public explanation is hilarious 😅
hmm found new java teacher love from india :)
0:00 Yup that "somebody" is my Teacher.
Sir please upload some on spring boot course
Can you do a tutorial about downloading java
I think that this style of explanation -
starting from the absolute bottom first, explaining all this st*pid keywords (of this alien language ;) -
is the best appraoch you can have.
Even if it takes some minutes longer,
it will clear out some questions that every newbie has at the beginning.
[even better would be some history on WHY this or that keyword had to be invented...]
Thanks man.
Thanks a lot John. Appreciate the clear explanation! :)
qq - you said the JRE will access your mail method like className.main()
so is it jre or jvm that accesses our main method ?
You can visualize it in terms of three circles JVM( Java Virtual Machine) I think being the largest and containing JRE (Java Runtime Environment) which contains the the program( .Class file) .
JRE is basically needed when you execute a program (.class file) and JVM when programming the java file ( JVM in simple terms converts the java file you have written into ".class" File which the JRE understands).
So JRE is the one that accesses the main method.
Unlucky for them or those then. Our good prof (but can be mean sometimes) explains it. And I think the very first thing also.
Thank you John for the video.
you are amazing teacher! Thank you
Lovely tutorial!
Finally, someone with the cojones to explain this thoroughly! Nice job.
Incidentally, have you ever considered becoming a Dean at a community college in Greendale CO? :P
Thanks! Hmm I somehow had not considered that very specific career path.
@@CodingWithJohn google 'community dean' 🤓 haha
Thank you so much for the video 🙏🙏🙏