Sunday, 29 January 2012
JAVA: Nested Class
Do you like this Article?
The class which is defined within another class is called nested class.
It can be divided into 2 types. They are - static nested class & non-static nested class
- Nested class which is declared static is static nested class.
- Its methods & variables are associated with is mother/outer class.
- It can be used only through object reference.
- It is accessed using enclosing class name. Example: MotherClass.StaticNestedClass
- It interacts with enclosing class or other class like any other top-level class.
- It has access to the other members of the mother class, even they are private.
- It can't define any static member itself.
- Instance of inner class only valid within the instance of the enclosed class, & has direct access to the methods & fields of the enclosing instance.
- To instantiate innerclass, 1st we need to instantiate the mother class. Example:
MotherClass.InnerClass iObj = MotherObject.new InnerClass();
Types of Inner Class
1. Local Inner Class
2. Anonymous Inner Class
Local Inner Class:
· The inner class which is declared within the body of a method is known as local inner class.
· It is not a member the enclosing class, hence doesn’t have any access specifies.
· It has access to all the members of the enclosing class, even any final variable
within the scope.
Anonymous Inner Class:
· The inner class which is declared within the body of a method and has no name
is known as anonymous inner class.
· It is accessible only at the point of its declaration.
Subscribe to:
Post Comments
(
Atom
)
Popular Posts
-
public - public means everyone can access it.That means it's in global scope. As, main method is called by JVM [ Java Virtual Machine...
-
throw is used to throw an exception in a program, explicitly . Whereas, throws is included in the method's declaration part, wi...
-
Singleton in one of the most popular yet controversial design pattern, in the world of object oriented programming. It's one of t...
-
Web Container / Servlet Container / Servlet Engine : In J2EE Architecture , a web container (also known as servlet container or ser...
-
Program compiles. But at runtime throws an error “NoSuchMethodError”.
-
Vector : It's synchronized. It's slower than ArrayList. It's generally used in ...
-
doGet(): protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, java.io.IOException – is a met...
-
In Java Programming Language , we must declare a variable name and type, before using it. The data type of a variable defines the th...
21 Responses to “ JAVA: Nested Class ”
29 January 2012 at 18:53
dis blog site is gettin betuh day by day....d best nested class expltion i've seen so far.thnx admin
5 March 2012 at 02:02
Thanks a lot!! :)
29 August 2018 at 15:29
Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
Devops training in Chennai
Devops training in Bangalore
Devops training in Pune
Devops Online training
Devops training in Pune
Devops training in Bangalore
Devops training in tambaram
7 September 2018 at 13:20
This is my 1st visit to your web... But I'm so impressed with your content. Good Job!
java training in chennai | java training in bangalore
java online training | java training in pune
selenium training in chennai
selenium training in bangalore
7 September 2018 at 13:20
Well you use a hard way for publishing, you could find much easier one!
java training in annanagar | java training in chennai
java training in marathahalli | java training in btm layout
java training in rajaji nagar | java training in jayanagar
12 September 2018 at 17:57
Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
angularjs Training in bangalore
angularjs Training in btm
angularjs Training in electronic-city
angularjs Training in online
12 September 2018 at 17:58
Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
angularjs Training in bangalore
angularjs Training in btm
angularjs Training in electronic-city
angularjs Training in online
3 October 2018 at 12:25
Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
AWS Training in Rajaji Nagar | Amazon Web Services Training in Rajaji Nagar
Amazon Web Services Training in Pune | Best AWS Training in Pune
AWS Online Training | Online AWS Certification Course - Gangboard
3 October 2018 at 12:25
Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
AWS Training in Rajaji Nagar | Amazon Web Services Training in Rajaji Nagar
Amazon Web Services Training in Pune | Best AWS Training in Pune
AWS Online Training | Online AWS Certification Course - Gangboard
4 October 2018 at 11:17
I really like the dear information you offer in your articles. I’m able to bookmark your site and show the kids check out up here generally. Im fairly positive theyre likely to be informed a great deal of new stuff here than anyone
python training in chennai
python training in Bangalore
Python training institute in chennai
6 October 2018 at 16:14
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
Devops Training in pune
DevOps online Training
9 November 2018 at 15:35
Good Post! Thank you so much for sharing this useful post, keep sharing!
DevOps Online Training
29 May 2019 at 11:42
Thanks for sharing this post, really this is helpful for me.
Java Training in Chennai
4 June 2019 at 17:53
You got an extremely helpful website I actually have been here reading for regarding an hour. I’m an initiate and your success is incredibly a lot of a concept on behalf of me.
dotnet online training
16 July 2019 at 11:58
The above article "JAVA: Nested Class" is so informative. This is more helpful for our
Learn best software testing online certification course class in chennai with placement
Best selenium testing online course training in chennai
Best online software testing training course institute in chennai with placement
Thanks for sharing.
3 September 2019 at 12:12
thanks for it i really got more information thanks for sharing keep updating web design company in velachery
29 October 2019 at 10:24
this is the best post blockchain online training
6 September 2021 at 20:49
UGC Net Commerce
12 April 2022 at 12:48
Some really good points you wrote here ... Great things ... I think you raised some really interesting points. Keep up the good work.
Best Data Analytics Courses in Bangalore
12 September 2023 at 12:28
great article. Thanks for sharing.
Java Classes in Nagpur
24 April 2024 at 23:22
Powerful paris dedicated server offering blazing speed, robust security, and 24/7 support for your online ventures. Elevate your server experience!
Post a Comment