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...
The amount of effort to make this video is tremendously helpful to me, tks a lot
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!
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
Thank you !!
Very good communicator. More people should watch!
Thank you so much for watching!!
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
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.
Your explanation is amazing. Clear and comprehensive. Hope you make something similar for Handling Exceptions in Java.
Thank you gina !! Awesome video . Really with an Object oriented thinking involved and not just cramming up the concepts . Many thanks !!
Exactly what I needed, thank you very much!
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?
It was a great video, I really liked it and learned in detail. Your teaching style is very impressive.
This was an amazing video - straightforward and understandable. Ty so much!
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!
wonderful! I needed to review this for a class and this was right on the money
Great video! Thanks for making it.
saved my life had a homework about this subject ,thank you very much
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.
this video is amazingly helpful thanks alot.
How come I didn't seen this before. thank you @Gina Sprint
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.
Really well done tutorial thank you very much for taking the time to explain the topic so well.
found this comment in udemy
Superb explanation thank you very much!
This video was very helpful, thanks!
truly informative
31:40 - "It broke my toe" (haha) but tbh this video was awesome and helpful. Thank you.
Excelent Gina! Thank you
thanks Gina for the wonderful video
Incredible explanation, thanks a lot
Excellent video thanks! Very well explained :)
Great explanation!
Thanks you so much!
beautifully explained , thank you .
I love you lol. This helped me a lot really. Thanks ^^
I like your work , hope you do more java tutorial
How do you access the members of the static class from the outer class?
Hi Gina, do you have any videos on Java collections framework ? Or know any good videos for it ?
You're doing god's work ❤❤
Amazing video!
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
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?
can you make a video on java string class
Amazing video, really is. Thanx
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.
Yes! It is all here: github.com/gsprint23/Java-Crash-Course thank you for watching and commenting!
awesome!
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
thanks a lot
Your students are lucky!!!!
there is only one thing I didn't like about this video is that you are using light mode theme .
Thank you very much.