How to use Nested Classes in Java (Static, Inner, Local, and Anonymous)

Поділитися
Вставка
  • Опубліковано 28 січ 2025
  • In this video, I show programming examples of the four different types of nested classes in Java (static, inner, local, and anonymous). I also review static vs. non-static.
    Source code available at: github.com/gsp...

КОМЕНТАРІ • 53

  • @jackytank
    @jackytank 3 роки тому +2

    The amount of effort to make this video is tremendously helpful to me, tks a lot

  • @dheeraj8334
    @dheeraj8334 4 роки тому +3

    I watched many tutorials but could never get the hang of nested classes until I stumbled upon this video. You made this topic seem so easy and simple. Subscribed to your channel. Thanks for this video and please don't stop making them!

  • @chaithdridi2718
    @chaithdridi2718 3 роки тому

    Thank you so much for explaining a tricky subject like this one i spend two days trying to understand it and your video sum it all i dont need to struggle further thank you again

  • @sharonleech9842
    @sharonleech9842 5 років тому +1

    Very good communicator. More people should watch!

    • @GinaSprint
      @GinaSprint  5 років тому +1

      Thank you so much for watching!!

  • @phetrusrodrigues8710
    @phetrusrodrigues8710 4 роки тому +2

    Amazing video! I’m in uni right now and this is just what I needed at the moment, I almost gave up on java but you‘be made me feel like I can actually learn this this complicated type of stuff after all

    • @HenryLeu
      @HenryLeu 4 роки тому

      Java is tough to learn. But once you grab it, you can handle any other programming languages more easily because Java is strongly typed language comparing to Python, etc.

  • @nichirvanali6714
    @nichirvanali6714 2 роки тому

    Your explanation is amazing. Clear and comprehensive. Hope you make something similar for Handling Exceptions in Java.

  • @saurabhc4278
    @saurabhc4278 4 роки тому +3

    Thank you gina !! Awesome video . Really with an Object oriented thinking involved and not just cramming up the concepts . Many thanks !!

  • @x9466x
    @x9466x 4 роки тому +6

    Exactly what I needed, thank you very much!

  • @stefanjankovic8253
    @stefanjankovic8253 3 роки тому +2

    This lecture is decent, it helped me understand how to write code for nested classes. But you missed the main point you should had explained, which is when to use inner, static nested, local or anonymous class. Also, little more explanation on the effectively final would be awesome. I failed to understand why I can't reassign its value. Why variable value must be assigned only once for local/anonymous class to use it without error?

  • @BoraKaan52
    @BoraKaan52 2 роки тому

    It was a great video, I really liked it and learned in detail. Your teaching style is very impressive.

  • @XXFlyer1989XX
    @XXFlyer1989XX 2 роки тому

    This was an amazing video - straightforward and understandable. Ty so much!

  • @generalreign3483
    @generalreign3483 4 роки тому

    This video was absolutely fantastic! Very well thought out explanations and I appreciated not brushing over out of scope concepts that are implemented as well. Thank you! Will be definitely watching other videos as well! Just finished this chapter in my book and was feeling a little lost in what it all really meant, this really helped!

  • @chessfrog42
    @chessfrog42 4 роки тому +1

    wonderful! I needed to review this for a class and this was right on the money

  • @TheTin123456789
    @TheTin123456789 4 роки тому +2

    Great video! Thanks for making it.

  • @kikyou8349
    @kikyou8349 3 роки тому

    saved my life had a homework about this subject ,thank you very much

  • @pjk7685
    @pjk7685 4 роки тому +2

    Awesome video! and wonderful teaching style! I like how you labeled the variables specifically in a way to show their role or class.
    Just one thing I wish you may have gone over how the anonymous class is implemented on interface?
    But you went over a lot and it was helpful. I will just look up how interface are used with anonymous classes.

  • @דניאל-ט9ד
    @דניאל-ט9ד 4 роки тому +1

    this video is amazingly helpful thanks alot.

  • @seeking.wisdom6066
    @seeking.wisdom6066 2 роки тому

    How come I didn't seen this before. thank you @Gina Sprint

  • @alexanderbardoczy263
    @alexanderbardoczy263 3 роки тому

    What an amazing video, thank you for such great explanation! Finally I found someone who can explain more complex topic in way I understood it as a beginner. It would be so great if you would do more videos on Java, Java Spring or SQL.

  • @Thebuddyguy
    @Thebuddyguy 4 роки тому +3

    Really well done tutorial thank you very much for taking the time to explain the topic so well.

  • @silvetdash7395
    @silvetdash7395 4 роки тому +1

    Superb explanation thank you very much!

  • @ShawCode
    @ShawCode 4 роки тому +2

    This video was very helpful, thanks!

  • @mohammedabahussain4562
    @mohammedabahussain4562 4 роки тому

    truly informative

  • @ankush_in_sync5998
    @ankush_in_sync5998 4 роки тому +2

    31:40 - "It broke my toe" (haha) but tbh this video was awesome and helpful. Thank you.

  • @AndreGMendes
    @AndreGMendes 3 роки тому

    Excelent Gina! Thank you

  • @abbasnasser5809
    @abbasnasser5809 4 роки тому +1

    thanks Gina for the wonderful video

  • @dmitrysakharnikov1358
    @dmitrysakharnikov1358 3 роки тому

    Incredible explanation, thanks a lot

  • @ferfykins
    @ferfykins 4 роки тому +1

    Excellent video thanks! Very well explained :)

  • @muzza49
    @muzza49 3 роки тому

    Great explanation!

  • @kanakagarwal7320
    @kanakagarwal7320 4 роки тому +1

    Thanks you so much!

  • @adityaguptabruce7179
    @adityaguptabruce7179 2 роки тому

    beautifully explained , thank you .

  • @AliEgemenB
    @AliEgemenB Рік тому

    I love you lol. This helped me a lot really. Thanks ^^

  • @fixthepolice6917
    @fixthepolice6917 4 роки тому

    I like your work , hope you do more java tutorial

  • @HenryLeu
    @HenryLeu 3 роки тому

    How do you access the members of the static class from the outer class?

  • @phetrusrodrigues8710
    @phetrusrodrigues8710 4 роки тому

    Hi Gina, do you have any videos on Java collections framework ? Or know any good videos for it ?

  • @satejbidvai
    @satejbidvai 4 роки тому

    You're doing god's work ❤❤

  • @dedz
    @dedz 2 роки тому

    Amazing video!

  • @dinkarinjosh
    @dinkarinjosh 4 роки тому

    Nice: However I came here to understand, how to use nested classes, not to understand what they are. If you could maybe make another video, detailing when to use which one? pros and cons?
    May be base the video from Effective programming part 2- Joshua Item 24, Favor static member over nonstatic member. Thanks

  • @randomTVSWE
    @randomTVSWE 4 роки тому

    what if my constructor looks like this for the innerclass:
    public CellA(int age,String dna) {
    this.age = age;
    this.dna = dna;
    }
    Then I can't use inner classes?

  • @jeevans8131
    @jeevans8131 5 років тому +1

    can you make a video on java string class

  • @Tarekconqueso
    @Tarekconqueso 4 роки тому

    Amazing video, really is. Thanx

  • @y8sang
    @y8sang 5 років тому +1

    Great video, would you mind sharing the source code, so we can follow along as you type and have us be able to play around with it to get a feel.

    • @GinaSprint
      @GinaSprint  5 років тому +1

      Yes! It is all here: github.com/gsprint23/Java-Crash-Course thank you for watching and commenting!

  • @rayxue3385
    @rayxue3385 4 роки тому +1

    awesome!

  • @HenryLeu
    @HenryLeu 4 роки тому

    How to run main() method from nested static class?
    I compile and run both. But they all seem to call the main() method from Outer class only. It only prints "Print from Outer class".
    javac Outer.java
    java Outer
    java Outer$StaticNestedClass
    class Outer{

    static class StaticNestedClass{
    public static void main(String args[]){
    System.out.println("Print from nested static class");
    }

    } // StaticNestedClass

    public static void main(String args[]){
    System.out.println("Print from Outer class");
    }

    } // Outer class

  • @akhilnukala896
    @akhilnukala896 4 роки тому

    thanks a lot

  • @vineet4957
    @vineet4957 4 роки тому

    Your students are lucky!!!!

  • @Bihariboyt-f7r
    @Bihariboyt-f7r 3 роки тому

    there is only one thing I didn't like about this video is that you are using light mode theme .

  • @yasinahlatc3552
    @yasinahlatc3552 3 роки тому

    Thank you very much.