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

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 พ.ย. 2020
  • 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
  • แนวปฏิบัติและการใช้ชีวิต

ความคิดเห็น • 275

  • @SponkADonk
    @SponkADonk 2 ปีที่แล้ว +352

    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 ปีที่แล้ว +3

      Can you please explain with an example.
      😊

    • @jumpz5561
      @jumpz5561 2 ปีที่แล้ว +3

      @@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 ปีที่แล้ว +1

      does this make sense?

    • @AK-wc1cv
      @AK-wc1cv 2 ปีที่แล้ว +25

      @@jumpz5561
      Or is it the other way round

    • @CodingWithJohn
      @CodingWithJohn  2 ปีที่แล้ว +66

      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.

  • @nick-yr7wu
    @nick-yr7wu 2 ปีที่แล้ว +62

    You seriously deserve more subscribers. You are an amazing teacher, thank you John

    • @sabeennawaz1001
      @sabeennawaz1001 ปีที่แล้ว +3

      Yes, that's why I told all of my classmates about John. We call him "Java John"

  • @alihaydarkaya3336
    @alihaydarkaya3336 2 ปีที่แล้ว +22

    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 หลายเดือนก่อน +3

    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 ปีที่แล้ว +1

    man i just stumbled upon your channel and im simply blown away by the quality of your content, it's gold

  • @victoriagee1059
    @victoriagee1059 2 ปีที่แล้ว +31

    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 ปีที่แล้ว +9

      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 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      It's quite straightforward once you get into the language. Initially, they give a vague definition so you can go on with the learning.

  • @jonathanbyrdmusic
    @jonathanbyrdmusic 2 หลายเดือนก่อน +2

    “Args” is actually the sound I make trying to understand computer language

  • @caffeinatedpanda1511
    @caffeinatedpanda1511 2 ปีที่แล้ว +3

    the scenario at the beginning was LITERALLY MY EXPERIENCE. tysm

  • @yadnyeshdesai6652
    @yadnyeshdesai6652 2 ปีที่แล้ว +3

    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.

  • @charityg4786
    @charityg4786 3 ปีที่แล้ว +19

    You are so enthusiastic when you teach. thanks for the lesson,it was easy to understand

    • @CodingWithJohn
      @CodingWithJohn  3 ปีที่แล้ว +6

      Very glad to hear that, thanks for watching!

  • @Catalyst313
    @Catalyst313 2 ปีที่แล้ว

    I don't wanna underrate any of your other videos but this one (especially the introduction) really got me insanely immersed

  • @heetwarm7819
    @heetwarm7819 2 ปีที่แล้ว

    After al those hours searching for explanations this is the only video I found helpful and entertaining!
    Keep it up!

  • @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!

  • @felifrit
    @felifrit ปีที่แล้ว

    this is my favorite channel for clearing up Java concepts, thank you so much John

  • @LaGrossePaulik
    @LaGrossePaulik ปีที่แล้ว +4

    Thank you so much!

  • @lastwish6428
    @lastwish6428 ปีที่แล้ว +3

    It feels good , when you already know all these stuff and still watching this complete video 🤗

  • @nobody_AskedMe
    @nobody_AskedMe 2 ปีที่แล้ว +1

    I started watching your videos yesterday and I am subscribed now, very interesting explanations!

  • @findlestick
    @findlestick 2 ปีที่แล้ว +1

    Way to clearly explain things. Thank you. 👍

  • @boulettefranck2627
    @boulettefranck2627 5 หลายเดือนก่อน

    Three years later, i've "super appreciated" your video ! Thx 🤩

  • @mahodaadikari4116
    @mahodaadikari4116 2 ปีที่แล้ว +1

    Your explanations are amazing. Keep up the good work. Wish you all the best ❤

  • @spancavil
    @spancavil ปีที่แล้ว

    Extremely useful! Congratz John.

  • @samaravadi3
    @samaravadi3 11 หลายเดือนก่อน

    I'm studying for my theory final in a couple days and you're helping me tremendously

  • @LanceLiebenberg
    @LanceLiebenberg ปีที่แล้ว +1

    Thanks so much bro. This honestly helped so much. Walking away a little more confident 👍

  • @Noah-vm8id
    @Noah-vm8id 2 ปีที่แล้ว

    This was a video I was always looking for when I was a beginner, thanks 🙏

  • @evanmcgillivray8697
    @evanmcgillivray8697 3 ปีที่แล้ว +4

    Thanks for the video! Great stuff man

  • @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"

  • @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.

  • @henriquesenadev2194
    @henriquesenadev2194 ปีที่แล้ว

    Great and simple video! Congrats and thanks

  • @mattmartin26
    @mattmartin26 ปีที่แล้ว +5

    Finally, a clear, succinct, and helpful explanation!

  • @steveymcsteve0717
    @steveymcsteve0717 2 ปีที่แล้ว

    Thank you for this. I was always wondering what it all did and I could never geta good answer.

  • @michalski9141
    @michalski9141 2 ปีที่แล้ว +1

    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

  • @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.

  • @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!

  • @saptarshidey7672
    @saptarshidey7672 2 ปีที่แล้ว +13

    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

  • @abdennadhermayssa1890
    @abdennadhermayssa1890 3 ปีที่แล้ว

    Super clear great job and thank you

  • @colbyboucher6391
    @colbyboucher6391 2 ปีที่แล้ว +7

    Might be good to note that those main args are typically used for advanced configuration options.

  • @user-dv1km1vk4b
    @user-dv1km1vk4b 9 หลายเดือนก่อน +1

    Thank you a lot❤❤ you are really helpful and you are very understandable

  • @franciscogrosso6533
    @franciscogrosso6533 ปีที่แล้ว

    Amazing explanation, thank u so much!

  • @JoseThomas-erpjose
    @JoseThomas-erpjose ปีที่แล้ว

    Wow, Never knew what it means. Super simple explaination

  • @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!!

  • @gopalkannan4934
    @gopalkannan4934 ปีที่แล้ว

    Thank you. It is useful for interview

  • @elvispontes4165
    @elvispontes4165 ปีที่แล้ว

    your videos are awesome!! Thanks a lot for sharing

  • @hexagonmagnetics569
    @hexagonmagnetics569 2 ปีที่แล้ว +1

    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!

  • @CodeKurdi
    @CodeKurdi 3 ปีที่แล้ว

    you are Legend man, lesson with fun and a lot info:)

  • @Galasssss
    @Galasssss 6 หลายเดือนก่อน

    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

  • @skylarngoi3262
    @skylarngoi3262 3 ปีที่แล้ว

    Thanks for your explanation..

  • @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

  • @FREDDYMAZENGE
    @FREDDYMAZENGE ปีที่แล้ว +1

    bro this video made me subscribe without any hesitations ...... l like the way you started your video

  • @mahodaadikari4116
    @mahodaadikari4116 2 ปีที่แล้ว

    Super cool and amazing explanation 👏🏻❤

  • @MrsWeasleyking15
    @MrsWeasleyking15 2 ปีที่แล้ว

    this was so clear thank youu

  • @ROSUJACOB
    @ROSUJACOB 2 ปีที่แล้ว

    Thank you John for the video.

  • @yashchandak8016
    @yashchandak8016 4 หลายเดือนก่อน

    Great explanation sir

  • @sebon11
    @sebon11 ปีที่แล้ว

    Lovely tutorial!

  • @pradiptonath4323
    @pradiptonath4323 2 ปีที่แล้ว

    Great explanation

  • @vineethgajjela747
    @vineethgajjela747 2 ปีที่แล้ว

    thanks for the explanation

  • @bladezxc
    @bladezxc ปีที่แล้ว

    Very nice videos, thank you so much

  • @MrSajjadgul
    @MrSajjadgul 2 ปีที่แล้ว

    A must like from me for all of your videos.

  • @justinbanza4751
    @justinbanza4751 2 ปีที่แล้ว

    Thank you very much for this video

  • @anonimosilva6723
    @anonimosilva6723 7 หลายเดือนก่อน +1

    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!!

  • @saraproetti5039
    @saraproetti5039 9 หลายเดือนก่อน

    you are amazing teacher! Thank you

  • @sandralane6379
    @sandralane6379 11 หลายเดือนก่อน

    Wonderful thank you!

  • @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.)

  • @tobiassteindl7792
    @tobiassteindl7792 2 ปีที่แล้ว

    Perfect, thank you

  • @Mohanadxd
    @Mohanadxd 3 ปีที่แล้ว +1

    John you are absolutely legend

  • @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[]

  • @davishek7
    @davishek7 2 ปีที่แล้ว

    Neither college teachers nor the textbooks ever explained what args do. Thanks for the clear explanation.

  • @vigneshwaranr680
    @vigneshwaranr680 2 ปีที่แล้ว

    Love your teaching. I mean it ❤

  • @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.

  • @ArjunKumar-zu2kl
    @ArjunKumar-zu2kl 2 ปีที่แล้ว

    Brilliant John....

  • @musicvibes1146
    @musicvibes1146 2 ปีที่แล้ว

    thanks john im a 7th grader trying to learn java this video helped out a lot thanks

  • @ericamuhammad5082
    @ericamuhammad5082 2 ปีที่แล้ว

    Thank you!

  • @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?

  • @shivjyotigarai2141
    @shivjyotigarai2141 10 หลายเดือนก่อน

    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 .

  • @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.

  • @DatGoodSir
    @DatGoodSir 2 ปีที่แล้ว

    Thank you

  • @Affiliation2Code
    @Affiliation2Code 4 หลายเดือนก่อน

    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!

  • @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.

  • @fyh8848
    @fyh8848 2 ปีที่แล้ว +6

    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?

  • @adelacristea153
    @adelacristea153 2 ปีที่แล้ว +1

    Yep.... that was my teacher, like:" no more questions" :-/
    Thank you for this great video. :D

  • @k0.9486
    @k0.9486 ปีที่แล้ว

    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.

  • @user-pr9pq8en2d
    @user-pr9pq8en2d 2 ปีที่แล้ว

    I love you man, I really needed this video.

  • @michaelmai25
    @michaelmai25 ปีที่แล้ว

    omg...bro is better teacher than all my professors combined lol GREAT VIDEO!

  • @m.morotha7095
    @m.morotha7095 ปีที่แล้ว

    Thank you,

  • @albertosoto4280
    @albertosoto4280 2 ปีที่แล้ว

    THANKS A LOT! People just saying "just copy this" was driving me nuts.

    • @CodingWithJohn
      @CodingWithJohn  2 ปีที่แล้ว +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.

  • @Nain_9
    @Nain_9 2 ปีที่แล้ว

    Thanks bro

  • @bacon37460
    @bacon37460 ปีที่แล้ว

    Perfect John, please upload design pattern serie in JAVA.

  • @snich1950
    @snich1950 2 ปีที่แล้ว

    Man. I have to tell your channel to my classmates, coz I'm having trouble explaining Java to them.

  • @brijkumar8207
    @brijkumar8207 ปีที่แล้ว +1

    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

  • @oldgamer1157
    @oldgamer1157 2 ปีที่แล้ว

    thanks bro

  • @danielnoguera2219
    @danielnoguera2219 2 ปีที่แล้ว

    Thanks a lot! Cheers from argentina

  • @Imsulaf
    @Imsulaf ปีที่แล้ว

    The story in the beginning is so accurate

  • @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.

  • @umangsingh2775
    @umangsingh2775 ปีที่แล้ว

    Just Great!!!!!

  • @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.

  • @stephanieezat-panah7750
    @stephanieezat-panah7750 ปีที่แล้ว

    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?

  • @clutchmadness
    @clutchmadness 2 ปีที่แล้ว

    You are fantastic.

  • @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)?

  • @yonatanshkolsky4396
    @yonatanshkolsky4396 2 ปีที่แล้ว

    You are amazing!!

  • @davannaleah
    @davannaleah 11 หลายเดือนก่อน

    If you could, please add to this about having multiple arguments rather than just one.