Java Main Method Explained - What Does All That Stuff Mean?

  Рет қаралды 220,810

Coding with John

Coding with John

3 жыл бұрын

Complete Java course: codingwithjohn.thinkific.com/...
Full tutorial - What does public static void main (String[] args) mean in all your Java programs?
Get the full explanation of the Java main method in this lesson.
Public? Static? Void? Everything about the Java main method is explained.
Learn or improve your Java programming by watching it being coded live in free video tutorial lessons!
Hey, I'm John! I'm a Lead Java Software Engineer who has been in the industry for over a decade, and I love teaching what I know.
Tell me what else you want to see!
Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.
📕 THE best book to learn Java, Effective Java by Joshua Bloch
amzn.to/36AfdUu
📕 One of my favorite programming books, Clean Code by Robert Martin
amzn.to/3GTPVhf
🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial
www.audibletrial.com/johnclean...
🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)
bit.ly/3QPNGko
📹Phone I use for recording:
amzn.to/3HepYJu
🎙️Microphone I use (classy, I know):
amzn.to/3AYGdbz
Donate with PayPal (Thank you so much!)
www.paypal.com/donate/?hosted...
☕Complete Java course:
codingwithjohn.thinkific.com/...
codingwithjohn.com

Пікірлер: 274
@SponkADonk
@SponkADonk 2 жыл бұрын
For whatever reason I have struggled with really understanding "static" and you just cleared it up for me. Thanks, John!
@beesetti.d.ssubhash5075
@beesetti.d.ssubhash5075 2 жыл бұрын
Can you please explain with an example. 😊
@jumpz5561
@jumpz5561 2 жыл бұрын
@@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
@jumpz5561
@jumpz5561 2 жыл бұрын
does this make sense?
@AK-wc1cv
@AK-wc1cv 2 жыл бұрын
@@jumpz5561 Or is it the other way round
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
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.
@alihaydarkaya3336
@alihaydarkaya3336 2 жыл бұрын
helloJohn, sometimes I’m having a language barriers but when you explain I don’t feel that. I appreciate it great explanation.
@InvinciRD
@InvinciRD 10 ай бұрын
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.
@ThatOtherAndi
@ThatOtherAndi Жыл бұрын
man i just stumbled upon your channel and im simply blown away by the quality of your content, it's gold
@yadnyeshdesai6652
@yadnyeshdesai6652 2 жыл бұрын
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.
@caffeinatedpanda1511
@caffeinatedpanda1511 2 жыл бұрын
the scenario at the beginning was LITERALLY MY EXPERIENCE. tysm
@heetwarm7819
@heetwarm7819 2 жыл бұрын
After al those hours searching for explanations this is the only video I found helpful and entertaining! Keep it up!
@nick-yr7wu
@nick-yr7wu 2 жыл бұрын
You seriously deserve more subscribers. You are an amazing teacher, thank you John
@sabeennawaz1001
@sabeennawaz1001 Жыл бұрын
Yes, that's why I told all of my classmates about John. We call him "Java John"
@nobody_AskedMe
@nobody_AskedMe 2 жыл бұрын
I started watching your videos yesterday and I am subscribed now, very interesting explanations!
@charityg4786
@charityg4786 3 жыл бұрын
You are so enthusiastic when you teach. thanks for the lesson,it was easy to understand
@CodingWithJohn
@CodingWithJohn 3 жыл бұрын
Very glad to hear that, thanks for watching!
@felifrit
@felifrit Жыл бұрын
this is my favorite channel for clearing up Java concepts, thank you so much John
@Catalyst313
@Catalyst313 2 жыл бұрын
I don't wanna underrate any of your other videos but this one (especially the introduction) really got me insanely immersed
@hexagonmagnetics569
@hexagonmagnetics569 2 жыл бұрын
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!
@findlestick
@findlestick 2 жыл бұрын
Way to clearly explain things. Thank you. 👍
@LaGrossePaulik
@LaGrossePaulik Жыл бұрын
Thank you so much!
@spancavil
@spancavil Жыл бұрын
Extremely useful! Congratz John.
@mahodaadikari4116
@mahodaadikari4116 2 жыл бұрын
Your explanations are amazing. Keep up the good work. Wish you all the best ❤
@LanceLiebenberg
@LanceLiebenberg Жыл бұрын
Thanks so much bro. This honestly helped so much. Walking away a little more confident 👍
@victoriagee1059
@victoriagee1059 2 жыл бұрын
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!
@kebbil
@kebbil 2 жыл бұрын
and never do
@nonnodacciaio704
@nonnodacciaio704 2 жыл бұрын
@@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
@vu5700
@vu5700 2 жыл бұрын
thats what your wife says the first time you are having sex with her
@theboss-by5gd
@theboss-by5gd 2 жыл бұрын
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
@pranavnyavanandi9710
@pranavnyavanandi9710 2 жыл бұрын
It's quite straightforward once you get into the language. Initially, they give a vague definition so you can go on with the learning.
@boulettefranck2627
@boulettefranck2627 5 ай бұрын
Three years later, i've "super appreciated" your video ! Thx 🤩
@Noah-vm8id
@Noah-vm8id 2 жыл бұрын
This was a video I was always looking for when I was a beginner, thanks 🙏
@evanmcgillivray8697
@evanmcgillivray8697 3 жыл бұрын
Thanks for the video! Great stuff man
@lastwish6428
@lastwish6428 Жыл бұрын
It feels good , when you already know all these stuff and still watching this complete video 🤗
@ramyareddy6190
@ramyareddy6190 2 жыл бұрын
yours the first channel i subscribed after watching many others.. you are just too good to be on you tube. I love your videos.
@samaravadi3
@samaravadi3 11 ай бұрын
I'm studying for my theory final in a couple days and you're helping me tremendously
@mattmartin26
@mattmartin26 Жыл бұрын
Finally, a clear, succinct, and helpful explanation!
@CodingWithJohn
@CodingWithJohn Жыл бұрын
Glad it was helpful!
@henriquesenadev2194
@henriquesenadev2194 Жыл бұрын
Great and simple video! Congrats and thanks
@steveymcsteve0717
@steveymcsteve0717 2 жыл бұрын
Thank you for this. I was always wondering what it all did and I could never geta good answer.
@mythicaldata6297
@mythicaldata6297 2 жыл бұрын
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"
@gopalkannan4934
@gopalkannan4934 Жыл бұрын
Thank you. It is useful for interview
@user-dv1km1vk4b
@user-dv1km1vk4b 10 ай бұрын
Thank you a lot❤❤ you are really helpful and you are very understandable
@gregorriusadolphus2729
@gregorriusadolphus2729 7 ай бұрын
This was very helpful....I just started learning Java last night (I was a JavaScript guy) and this really cleared things up! Gracias!!
@JoseThomas-erpjose
@JoseThomas-erpjose Жыл бұрын
Wow, Never knew what it means. Super simple explaination
@anth0ni33
@anth0ni33 Жыл бұрын
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.
@colbyboucher6391
@colbyboucher6391 2 жыл бұрын
Might be good to note that those main args are typically used for advanced configuration options.
@FREDDYMAZENGE
@FREDDYMAZENGE Жыл бұрын
bro this video made me subscribe without any hesitations ...... l like the way you started your video
@franciscogrosso6533
@franciscogrosso6533 Жыл бұрын
Amazing explanation, thank u so much!
@abdennadhermayssa1890
@abdennadhermayssa1890 3 жыл бұрын
Super clear great job and thank you
@jonathanbyrdmusic
@jonathanbyrdmusic 3 ай бұрын
“Args” is actually the sound I make trying to understand computer language
@hexagonmagnetics569
@hexagonmagnetics569 2 жыл бұрын
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!
@saptarshidey7672
@saptarshidey7672 2 жыл бұрын
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
@CodeKurdi
@CodeKurdi 3 жыл бұрын
you are Legend man, lesson with fun and a lot info:)
@elvispontes4165
@elvispontes4165 Жыл бұрын
your videos are awesome!! Thanks a lot for sharing
@furkancakin1553
@furkancakin1553 2 жыл бұрын
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
@yashchandak8016
@yashchandak8016 5 ай бұрын
Great explanation sir
@philbowden
@philbowden 4 ай бұрын
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?
@Galasssss
@Galasssss 7 ай бұрын
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
@saraproetti5039
@saraproetti5039 9 ай бұрын
you are amazing teacher! Thank you
@skylarngoi3262
@skylarngoi3262 3 жыл бұрын
Thanks for your explanation..
@mahodaadikari4116
@mahodaadikari4116 2 жыл бұрын
Super cool and amazing explanation 👏🏻❤
@anonimosilva6723
@anonimosilva6723 7 ай бұрын
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!!
@MrSajjadgul
@MrSajjadgul 2 жыл бұрын
A must like from me for all of your videos.
@MrsWeasleyking15
@MrsWeasleyking15 2 жыл бұрын
this was so clear thank youu
@ROSUJACOB
@ROSUJACOB 2 жыл бұрын
Thank you John for the video.
@bladezxc
@bladezxc Жыл бұрын
Very nice videos, thank you so much
@sebon11
@sebon11 Жыл бұрын
Lovely tutorial!
@tibettenballs4962
@tibettenballs4962 2 жыл бұрын
learning java has helped me realize the underworkings of languages. wonder what C++ would be like now (did it in high school 26 years ago.)
@Mohanadxd
@Mohanadxd 3 жыл бұрын
John you are absolutely legend
@sandralane6379
@sandralane6379 11 ай бұрын
Wonderful thank you!
@michalski9141
@michalski9141 2 жыл бұрын
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
@pradiptonath4323
@pradiptonath4323 2 жыл бұрын
Great explanation
@justinbanza4751
@justinbanza4751 2 жыл бұрын
Thank you very much for this video
@vineethgajjela747
@vineethgajjela747 2 жыл бұрын
thanks for the explanation
@vodkaaaxxx
@vodkaaaxxx 2 жыл бұрын
well, you can explain the main name is because of the fact that the JVM is actually looking up the method via reflection. Basically you specify the class you run, for that class, reflection looks up for a method called exactly "main" with arg0 of type String[]
@akeemlouigarde4946
@akeemlouigarde4946 2 жыл бұрын
Thank you John
@samim7373
@samim7373 Жыл бұрын
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.
@vigneshwaranr680
@vigneshwaranr680 2 жыл бұрын
Love your teaching. I mean it ❤
@musicvibes1146
@musicvibes1146 2 жыл бұрын
thanks john im a 7th grader trying to learn java this video helped out a lot thanks
@ArjunKumar-zu2kl
@ArjunKumar-zu2kl 2 жыл бұрын
Brilliant John....
@fyh8848
@fyh8848 2 жыл бұрын
Interesting, thx. Btw, the word “main” is inherited from C language. main function is entrance point in C.
@10F2C
@10F2C 2 жыл бұрын
the int main{} thingy?
@tobiassteindl7792
@tobiassteindl7792 2 жыл бұрын
Perfect, thank you
@Mnogojazyk
@Mnogojazyk Жыл бұрын
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.
@valoriebroderick
@valoriebroderick Жыл бұрын
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.
@user-pr9pq8en2d
@user-pr9pq8en2d 2 жыл бұрын
I love you man, I really needed this video.
@ericamuhammad5082
@ericamuhammad5082 2 жыл бұрын
Thank you!
@katiescape
@katiescape Ай бұрын
My mind always asks me 'why' and when I can't get the answers my learning shuts down, thank you for this explanation!
@suwatchainanchai6637
@suwatchainanchai6637 2 жыл бұрын
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.
@davishek7
@davishek7 2 жыл бұрын
Neither college teachers nor the textbooks ever explained what args do. Thanks for the clear explanation.
@adelacristea153
@adelacristea153 2 жыл бұрын
Yep.... that was my teacher, like:" no more questions" :-/ Thank you for this great video. :D
@TezlaByte
@TezlaByte 2 жыл бұрын
Haven't seen the video yet... But that's exactly what I asked yeaaars ago trying to do C# I never progressed.
@sasa-bv9gu
@sasa-bv9gu 6 ай бұрын
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)?
@yashjani99
@yashjani99 2 жыл бұрын
Printing that args[0] gives the actual executable name in case of C/c++, can we similarly access the executable file name using this args variable? Or if there is other way, then how to do that?
@shivjyotigarai2141
@shivjyotigarai2141 11 ай бұрын
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 .
@vaibhavkulshreshtha6
@vaibhavkulshreshtha6 9 ай бұрын
Is there any reason to leave line 6 and writing public static voin main(String[] args) { in 7th line Just wondering cuz even if you write it on 6th line it still work.
@preetavasan8958
@preetavasan8958 2 жыл бұрын
Can you do a series on backtracking and dynamic programming
@bacon37460
@bacon37460 Жыл бұрын
Perfect John, please upload design pattern serie in JAVA.
@MrJayenta
@MrJayenta 2 жыл бұрын
Sir please upload some on spring boot course
@duongvutung2876
@duongvutung2876 Жыл бұрын
Thank you
@MUZICSTATION1
@MUZICSTATION1 5 ай бұрын
Hi John, I've one doubt Can we use (Object[ ] args) instead of ( String [ ] args) in main method. If we execute that program by add Object[] will not give output, why? 😅
@michaelmai25
@michaelmai25 Жыл бұрын
omg...bro is better teacher than all my professors combined lol GREAT VIDEO!
@m.morotha7095
@m.morotha7095 Жыл бұрын
Thank you,
@danielnoguera2219
@danielnoguera2219 2 жыл бұрын
Thanks a lot! Cheers from argentina
@alexzink4451
@alexzink4451 5 ай бұрын
Hello, Sir! We'd all really appreciate if you break down SOLID on this channel, especially LSP🙏🙏🙏
@Nain_9
@Nain_9 2 жыл бұрын
Thanks bro
@brijkumar8207
@brijkumar8207 Жыл бұрын
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?
@CodingWithJohn
@CodingWithJohn Жыл бұрын
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.
@brijkumar8207
@brijkumar8207 Жыл бұрын
@@CodingWithJohn I already code but I get confused on how to start
@albertosoto4280
@albertosoto4280 2 жыл бұрын
THANKS A LOT! People just saying "just copy this" was driving me nuts.
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
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.
@bhartiyagamerzzyt_
@bhartiyagamerzzyt_ 11 ай бұрын
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 ?
@NotreallySerious695
@NotreallySerious695 11 ай бұрын
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.
@clutchmadness
@clutchmadness 2 жыл бұрын
You are fantastic.
@Imsulaf
@Imsulaf Жыл бұрын
The story in the beginning is so accurate
@oldgamer1157
@oldgamer1157 2 жыл бұрын
thanks bro
How to Run Java Programs With Command Prompt (cmd) and Notepad in Windows
5:43
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1 МЛН
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 12 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 170 #shorts
00:27
When You Get Ran Over By A Car...
00:15
Jojo Sim
Рет қаралды 4,7 МЛН
Always be more smart #shorts
00:32
Jin and Hattie
Рет қаралды 40 МЛН
Learn Java in One Video - 15-minute Crash Course
14:54
Coding with John
Рет қаралды 655 М.
MAIN METHOD EXPLANATION - JAVA PROGRAMMING
7:46
Sundeep Saradhi Kanthety
Рет қаралды 167 М.
Lambda Expressions in Java - Full Simple Tutorial
13:05
Coding with John
Рет қаралды 710 М.
Array vs. ArrayList in Java Tutorial - What's The Difference?
17:36
Coding with John
Рет қаралды 499 М.
Java Custom Exceptions Tutorial - It's Way Easier Than You Think
14:29
Coding with John
Рет қаралды 149 М.
Java toString method 🎉
6:39
Bro Code
Рет қаралды 87 М.
Static vs Non-Static Variables and Methods In Java - Full Simple Tutorial
11:29
Multithreading in Java Explained in 10 Minutes
10:01
Coding with John
Рет қаралды 886 М.
Java methods 📞
11:05
Bro Code
Рет қаралды 121 М.
孩子多的烦恼?#火影忍者 #家庭 #佐助
0:31
火影忍者一家
Рет қаралды 24 МЛН
СБОР УРОЖАЯ (@bori_csaladi_gazdasag - TikTok)
0:16
В ТРЕНДЕ
Рет қаралды 8 МЛН
I respect children #respect #respectshorts
0:34
Movie Copy
Рет қаралды 11 МЛН
How did we do? 👀😬😅 @RaenaTripleCharm 🍍 | Gabriella Triple Charm #shorts
0:19
ОЧЕНЬ ВКУСНЫЙ БУТЕРБРОД 🍞
0:49
КиноХост
Рет қаралды 4,2 МЛН