Static vs Non-Static Variables and Methods In Java - Full Simple Tutorial

Sdílet
Vložit
  • čas přidán 26. 06. 2024
  • Struggling with static vs nonstatic in Java? You found the perfect video!
    ☕ Complete Java course: codingwithjohn.thinkific.com/...
    For beginner Java programmers, the concept of static vs nonstatic fields and methods can be incredibly confusing. I know it was for me!
    But it doesn't have to be difficult. We'll go over EXACTLY what the difference is, how they're used, and when you should make your methods and fields static or nonstatic in your programs.
    Learn or improve your Java by watching it being coded live!
    Hi, I'm John! I'm a Lead Java Software Engineer and I've been in the programming industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java learners.
    Let me know what else you'd like 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
    📹Camera I use for recording:
    amzn.to/3wlXcmR
    🎙️Microphone I use (classy, I know):
    amzn.to/3AYGdbz
    Donate with PayPal (Thank you so much!)
    www.paypal.com/donate/?hosted...
    00:00 What Non-Static means
    03:34 What Static means
    05:53 Why can't I access my Non-Static variable?
    08:42 Using Static for Constants
    10:30 When to make something Static or Non-Static?
    ☕Complete Java course:
    codingwithjohn.thinkific.com/...
    codingwithjohn.com

Komentáře • 232

  • @a7mdbest15
    @a7mdbest15 Před 4 měsíci +34

    Anyone wants to learn java, this is the destination

  • @gunnerxt
    @gunnerxt Před 9 měsíci +106

    Hey John, I truly appreciate the way you explain concepts. There's one aspect I'd hope you cover: Serialization and Deserialization. Thank you for keeping up the good work. You make so many people want to code

  • @neon0wl2107
    @neon0wl2107 Před 9 měsíci +22

    1:52 cleared a doubt i have been having for over 5 years. Thanks a lot.

  • @micleh
    @micleh Před 9 měsíci +33

    Just in the nick of time. My students are presently struggling with static and non static and this video might help them look at both concepts from yet another angle.
    Thanks again for your short but incredibly succinct videos.

  • @matiloki
    @matiloki Před 5 měsíci +5

    My goodness, years using it without knowing how to explain this to other people. Now I can teach it. Thanks!!!

  • @kingslymatthew5586
    @kingslymatthew5586 Před 9 měsíci +15

    Your contents are easy to follow & understand. Thanks John.✌🏼

  • @yte6598
    @yte6598 Před 9 měsíci +11

    Finding your channel is luck for me! I had avoided to learn Java because of difference from any other language and stream of fearful keywords. But thanks to your teaching that anyone can understand and well-made examples in your videos and courses, I could understand what mean of keywords and how to code in Java. Not only that, I find attraction of Java and enjoy coding with it! I sincerely hope to see your videos more. Thanks!

  • @akshitmittal1251
    @akshitmittal1251 Před 16 dny +1

    U have very POSITIVE vibe. There are v less people like u. Thanks for all tutorials

  • @sgretsch
    @sgretsch Před 8 měsíci +7

    These lectures are the best ones that I've seen on the Internet, even compared with L/U big monsters. Not only knowledge, but hidden rocks that you can collide with, everything explained. Thanks to the author!

  • @olivierbegassat851
    @olivierbegassat851 Před 8 měsíci +5

    Those explanations are crystal clear ... You are an amazing teacher, and those lessons are invaluable 😃

  • @jessicar5549
    @jessicar5549 Před 8 měsíci +1

    John. I just need to say I am so thankful I’ve run across your channel. Thank for educating us all!!!

  • @Hassan-lv9di
    @Hassan-lv9di Před 6 měsíci

    Simplicity, straight forward, depth.. yep that's CodingWithJohn !
    I love you man! KEEP UP THE HARD WORKING

  • @timmann109
    @timmann109 Před 9 měsíci +2

    Best description I have seen on this topic. Thanks

  • @user-rm4oq9uh8j
    @user-rm4oq9uh8j Před 2 měsíci

    John, you're the man!!! I have finished a bootcamp and learned core Java in 3 months from zero. Now, after a year, going through all the topics with your videos is perfecting my knowledge and making me feel more comfortable with things that I've learned. Your efforts in sharing your knowledge are very much appreciated!

  • @SupahBro535
    @SupahBro535 Před 2 měsíci +2

    Java was the one language I was intimidated and frustrated with, until I found your channel. Then it became my favorite language to work with!

  • @lootster
    @lootster Před 5 dny

    This 11 mins video probably saves you HOURS of research on the internet what the keyword Static means, you're the best John! 👏

  • @AdrianTregoning
    @AdrianTregoning Před 9 měsíci +2

    Pure gold, that made it easy to understand. Thanks John.

  • @tshepisoseabi1069
    @tshepisoseabi1069 Před 2 měsíci

    You have no idea how long I've been struggling to understand this, thank you John.

  • @magadiflo-dev
    @magadiflo-dev Před 9 měsíci +2

    He really has a simple and very understandable way of explaining these concepts. Thank you very much for sharing them. Greetings from Peru

  • @andyhicks3472
    @andyhicks3472 Před 5 měsíci +1

    This is the clearest explanation of static I have come across. Thank you!

  • @raderadovanovic9052
    @raderadovanovic9052 Před 9 měsíci +1

    Very nice explanation. Keep up with a good work John!

  • @user-jc6es2ku6d
    @user-jc6es2ku6d Před 15 dny

    this is such a live saver for me, who was forced to jump from C to Java, and lost all motivation at the first days via confusion. Now with a better explained Theory and Concepts by you, @Josh, it is strarting to make sense and become understandable, and i also tend to like it more, eventhough i do bad with a little more abstract languages. thanks :)

  • @Kuba200411
    @Kuba200411 Před 9 měsíci +21

    Hi John! Could you do some videos about design patterns like Singleton, and others?

  • @TerryPlays
    @TerryPlays Před 9 měsíci

    Great to see you back with a new video! Thanks

  • @JuanRamirez-fx3tf
    @JuanRamirez-fx3tf Před 9 měsíci

    Evening John, I've been following you since I started a Java course this summer. I've finished a project using static, I use the concept, but I do no know why. I am going to enjoy this video.

  • @GabrielLima-yq6qp
    @GabrielLima-yq6qp Před 9 měsíci +22

    how did you know that i needed this video? your content is so amazing keep going

    • @CodingWithJohn
      @CodingWithJohn  Před 9 měsíci +23

      I have eyes everywhere 👀

    • @erikseyranyan5490
      @erikseyranyan5490 Před 6 měsíci

      Love you bro. You are the best teacher. Understand your videos are very easy your methods of teaching are the best@@CodingWithJohn

    • @muhammetalimutlu6748
      @muhammetalimutlu6748 Před 5 měsíci

      @@CodingWithJohn mr you are great thank you

    • @LANternFly1001
      @LANternFly1001 Před 3 měsíci

      @@CodingWithJohn I pray for your codiness Saint John.

  • @srishtijoshi5980
    @srishtijoshi5980 Před 17 dny

    Your examples are spot on. Its easy to understand the difficult concept when you explain it.

  • @gaetanolopez7779
    @gaetanolopez7779 Před 4 měsíci

    I utilized your content as a reference for my university assignment, citing it in APA format. Your material was incredibly helpful, simplifying complex concepts for easy comprehension. Hopefully, the university won't find any issues with my referencing!

  • @davidorevic6651
    @davidorevic6651 Před 7 měsíci

    Thank you so much John!I was questioning myself a lot regarding this matter 💥

  • @christo4520
    @christo4520 Před 3 měsíci

    Another amazingly explained concept man!!!

  • @gabrielfono844
    @gabrielfono844 Před 4 měsíci

    Sir
    I am going to lie
    you are absolutely amazing.
    I taught programming 3 years ago and I have been working professionally for almost two years.
    always your videos are amazing.
    Thanks so much.

  • @mayurpatel481
    @mayurpatel481 Před 8 měsíci

    It was very nicely explained. Thanks John.

  • @lucostz
    @lucostz Před 28 dny

    Super clear, thanks!

  • @lemagamy
    @lemagamy Před 9 měsíci

    great video John, your yt channel and videos are amazing!

  • @shaygoldin
    @shaygoldin Před 9 měsíci

    Hi John. thank you so much! your videos are truly the best!

  • @Hianfita
    @Hianfita Před 4 měsíci

    Best explanation I've ever heard! Thanks a lot!!!!

  • @rachiimade4073
    @rachiimade4073 Před 2 měsíci

    it was a very clear explanation ,thank for your efforts for making this get sence.

  • @bioblade87
    @bioblade87 Před 8 měsíci

    Someone told me that Static is the same as the "Shared" keyword in VB. Calling it "Shared" instantly made sense to me as opposed to "Static".
    Goes without saying, great video and breakdown of the topic.

  • @kevinkoomson7873
    @kevinkoomson7873 Před měsícem

    This is gold. Thanks John

  • @yoyomaster223
    @yoyomaster223 Před 4 měsíci

    Relearning Java right now after close to 8 years never touching it. I remember never understanding what static meant and how it was used. Gave me so much grief trying to figure it out. Been debugging a few if statements today for close to 5 hours, come to find out it had to do with needing a static declaration.
    Long story short, found this video and everything finally made sense! Thank you!

  • @muhannadFahmy
    @muhannadFahmy Před 9 měsíci

    It is sooo clear, thanks to you

  • @mathewajayi2482
    @mathewajayi2482 Před 6 měsíci

    ❤ Thank you for this...the concept is so much simpler.

  • @thiagogo1995
    @thiagogo1995 Před 5 měsíci

    Great video! Very easy to understand. Thank you very much.

  • @Carll19
    @Carll19 Před 3 měsíci

    Before your video, I felt the same, now finally ‘static’ is clear for me, thanks!

  • @jerrygord3131
    @jerrygord3131 Před 7 dny

    This was extremely helpful, thank you so much!

  • @donaldbunce2741
    @donaldbunce2741 Před 5 měsíci

    John, this is an excellent explanation! I'm grateful.

  • @vogiansatnaaihonglien6780
    @vogiansatnaaihonglien6780 Před 9 měsíci

    Thanks a lot for your video! Tbh i was stuck with the same problem of not able to access the rest controller class in Spring since non-static class and method cannot be access without instantiated, so after i watched your video i went to look back at some information and found out that you can just autowired the class object from the beginning :v
    You really helped me pointing out the vagueness of my understanding about all this static non-static thing, thank you!

  • @kraxmalism
    @kraxmalism Před 6 měsíci

    it is no longer confusing after this video. appreciated!

  • @amaralensheriff
    @amaralensheriff Před 5 měsíci

    Awesome John, please keep on doing more such great contents.

  • @paulthomas1052
    @paulthomas1052 Před 9 měsíci

    Very useful video as usual - cheers !

  • @user-rm1cq1kx4b
    @user-rm1cq1kx4b Před 8 měsíci +1

    This is a very good video. I used to abuse the "static" keyword, and it caused so many bugs that I am only now beginning to understand 3 years into my coding. Lol

  • @Do11an
    @Do11an Před 3 měsíci

    Perfect video, thank you!

  • @codeZarathustra
    @codeZarathustra Před 9 měsíci

    Thanks very much Jhon.

  • @DejiAdegbite
    @DejiAdegbite Před 6 měsíci

    Here's me shouting at you in the comments: GREAT VIDEO. I LOVE THAT YOUR VIDEOS ARE SHORT, SIMPLE AND STRAIGHT TO THE POINT. 😄

  • @farah2521
    @farah2521 Před 8 měsíci

    Thank you so much! This helped so much

  • @davod9638
    @davod9638 Před 7 měsíci +4

    Hey John,
    Can you make a video about Java modules? Really important, thank you. You are the best!

  • @Sagittarius182
    @Sagittarius182 Před 3 měsíci

    Very nice explanation. Thank you very much 😸👌

  • @solvejtodd2960
    @solvejtodd2960 Před 26 dny

    THE Best explanation of this on the internet.

  • @cvl--
    @cvl-- Před 9 měsíci +2

    I've learned by the terms "static"/"instance" when talking about methods and variables. I think it is less confusing than static or non-static, specially for beginners.

  • @laali_puppy
    @laali_puppy Před 9 měsíci

    Great explanation, thanks a lot!

  • @cisco8237
    @cisco8237 Před 9 měsíci

    Thanks for the video really helped me

  • @sandra_witch
    @sandra_witch Před 5 měsíci

    You're a great teacher, thank you so much!

  • @jonathan2350
    @jonathan2350 Před 5 měsíci

    Thanks, understood it!

  • @bytecode5834
    @bytecode5834 Před 9 měsíci

    Very helpful, many thanks!

  • @Ironman-sn4ct
    @Ironman-sn4ct Před 6 měsíci +1

    Hey Sir! I am from India and I am learning java by watching your videos ❤❤ Thank you Sir 😊😊

  • @felipel.r.637
    @felipel.r.637 Před 9 měsíci

    Brilliant as always, thank yu very much

  • @user-qw6dy5tg8j
    @user-qw6dy5tg8j Před 6 měsíci

    That was very informative, thanks a lot

  • @cyberkiller83
    @cyberkiller83 Před 9 měsíci

    Hi john, as always, amazing video. You miss two things thought.
    1 Miss to mention that when you create static members of a class, the system automatically make those instances one they are used the first time.
    2 MIss to mention the static code blocks static { } and how this code blocks are called the first time a static member is called, so those can be used like some kind of constructor.
    Great videos!

  • @personalaccount1515
    @personalaccount1515 Před 9 měsíci

    Hi. I really love all your videos, PLS keep doing it,. Thanks for everything,

  • @KARTIKKUMAR-vm8ht
    @KARTIKKUMAR-vm8ht Před 8 měsíci

    Hey jhon, i have seen most of your videos on java and they are good. I have a request Please make videos on spring and spring boot as well

  • @jayt675
    @jayt675 Před 5 měsíci

    Extremely helpful.

  • @ryyyyy2010
    @ryyyyy2010 Před 8 měsíci

    very helpful video. tysm

  • @axmy1776
    @axmy1776 Před 8 měsíci

    Thank you so much John!

  • @expekeyt2998
    @expekeyt2998 Před 9 měsíci

    Thank you for your teaching!

  • @andreperez5850
    @andreperez5850 Před 9 měsíci

    Glad to see you again sir

  • @Leetneetcode1729
    @Leetneetcode1729 Před 9 měsíci

    much needed thanks very cool

  • @johnandrewbotros8972
    @johnandrewbotros8972 Před 9 měsíci

    your channel is very helpful i learned so much from it keep uploading

    • @CodingWithJohn
      @CodingWithJohn  Před 9 měsíci

      I don't get to as often as I'd like but I'll keep it going!

  • @beetsreliable
    @beetsreliable Před 5 měsíci

    Very helpful!

  • @julie3447
    @julie3447 Před 7 měsíci

    I like how u make it so simple. thank u so much

  • @wasim_17
    @wasim_17 Před 9 měsíci

    Nice explanation.

  • @yashsureka9552
    @yashsureka9552 Před 3 měsíci

    you teach so difficult concepts so easily

  • @zladtv1456
    @zladtv1456 Před 7 měsíci

    Very useful!

  • @MooseAntlers-ym4de
    @MooseAntlers-ym4de Před 2 měsíci

    WHY ARE YOUR VIDEOS SO GOOD AND EASY TO UNDERSTAND DO YOU KNOW HOW MANY PEOPLE YOU HAVE SAVED THANK YOU SO MUCH 🙏🙏🙏🙏🙏🙏🙏

  • @anghamjbeli3037
    @anghamjbeli3037 Před 9 měsíci

    great explanation

  • @fathimasalooja
    @fathimasalooja Před měsícem

    awesome,Thank you.

  • @dayshiasweet
    @dayshiasweet Před 9 měsíci

    Amazing explanation

  • @SUMITYADAV-cy9hf
    @SUMITYADAV-cy9hf Před 3 měsíci

    hey John !!! amazing work requesting you to create a spring framework course as well .

  • @bumilib9785
    @bumilib9785 Před 9 měsíci

    you're the best! thanks

  • @Askalon08
    @Askalon08 Před 7 měsíci +3

    Can you pls make a video about modules in Java? ur the best❤

  • @Avinash-fm6we
    @Avinash-fm6we Před 2 měsíci

    It was a very good video for anyone to understand Static vs Non-Static Variables and Methods In Java.

  • @Mirtguitar
    @Mirtguitar Před 6 měsíci

    Great tutorial

  • @minfiresmanyeah
    @minfiresmanyeah Před 7 měsíci

    Thank you!!

  • @Shamim-oh8rw
    @Shamim-oh8rw Před 5 měsíci

    I'm from lran and I don't know English pretty much but you speak simply and I understand it keep going my friend ❤

  • @shahabshafiee3333
    @shahabshafiee3333 Před 9 měsíci

    Best Java channel ever.

  • @Aporajita_.29
    @Aporajita_.29 Před 3 měsíci

    I'm in 10th grade rn and this video of yours has helped me alot
    Thank you John

  • @mohammadbayat1635
    @mohammadbayat1635 Před 5 měsíci

    Wow, thanks John

  • @hayetaitouazzou7290
    @hayetaitouazzou7290 Před 9 měsíci

    Amazing !!

  • @Necrobin
    @Necrobin Před 13 dny

    beautiful, thanks

  • @kokosensei5231
    @kokosensei5231 Před 6 měsíci

    Thank you!

  • @armenuhiyeghoyan5419
    @armenuhiyeghoyan5419 Před měsícem

    Your English is perfect.The best one for me to develop speaking skills.