Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Nested and Inner classes
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Rishikant Lal
Nested and Inner classes
1 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners


What is the significance of Inner Classes and Static Inner Classes? or Why are nested classes used?


Advertisement
View Answers

January 27, 2011 at 2:53 PM


Hi Friend,

When a class is defined within another class then such a class is called a nested class.

Inner class is a non static class declared inside another class.Non-static inner class keep the reference of outer class and allow to access member variable of outer class. It helps in defining an interface of a class.

We use nested classes because of the following reasons:

It is a way of logically grouping classes that are only used in one place.

It increases encapsulation.Nested classes can lead to more readable and maintainable code.

For more information, visit the following links:

http://www.roseindia.net/help/java/n/java-nested-class.shtml

http://www.roseindia.net/java/master-java/inner.shtml

Thanks



Related Tutorials/Questions & Answers:
Nested and Inner classes
Nested and Inner classes  What is the significance of Inner Classes and Static Inner Classes? or Why are nested classes used?   Hi Friend... a nested class. Inner class is a non static class declared inside another class.Non
Member Classes, Inner Nested Classes in java
Member Classes        Member classes are defined within the body of a class. We can use member classes anywhere within the body of the containing class. We declare member classes
Advertisements
Inner Nested Classes
Inner Nested Classes       Non-static nested classes are slightly different from static nested classes, a non-static nested class is actually associated
Inner classes
Inner classes   Hi I am bharat . I am student learning java course . I have one question about inner classes . question is how to access the instance method of Non-static classes which is defined in the outer
Nested classes: Examples and tutorials
within another class, such class is called a nested class. Inner classes can... Nested classes: Examples and tutorials       Nested classes Here is another advantage of the Java
Anonymous Inner Classes - Anonymous Inner Classes tutorial
.style1 { text-align: center; } Anonymous Inner Classes Except the inner class, there are two types of supplementary  inner classes... inner classes. The class declared inside the body of a method without naming
Java inner class and static nested class
Java inner class and static nested class  Java inner class and static nested class
Nested classes
are known as nested classesInner classes can be either named... of nested classes, which are as under: i)  Static classes ii) Inner... Nested classes      
Inner Classes In Java
Inner Classes In Java      ... can be termed as the inner classes. --  Inner classes provides an elegant.... Local classes   4. Anonymous classes -- The term "nested
Inner class in java
Inner class in java In this example we will describe inner classes in java. Inner class declared inside a class. The inner class also call Nested classes... class parts of Nested Class. Inner classes are related by different names
How are Anonymous (inner) classes used in Java?
How are Anonymous (inner) classes used in Java?  How are Anonymous (inner) classes used in Java
how to use nested classes in swing concepts
how to use nested classes in swing concepts  i am working on swing concepts . i want to know how to use the nested classes in swings
Static Nested Classes
Static Nested Classes      .... Memory to the objects of  any static nested classes are allocated...; .... }   } Static nested classes can
Use of Local Inner class
class. Such a class is defined as Nested Class or Local Inner class. The Nested Class are classified into - 1)Static Nested Inner class are declared static called static Nested classes. 2)Non-Static Nested classes are those classes
Inner class in java
Non-static nested classes are slightly different from static nested classes, a non-static nested class is actually associated to an object rather than to the class in which it is nested. For more details click on the following link
java inner class - Java Beginners
java inner class  What is the difference between the nested class... declared inside another class. 2)Nested classes are associated with the enclosing class itself, whereas inner classes are associated with an object
Nested class
nested classes are: It is a way of logically grouping classes that are only used...Nested class  What is nested class?  when a class is defined within another class then such a class is called a nested class. Nested
inner class - Java Interview Questions
data. Non-static nested classes are called inner classes. It has access...Java Inner Class  How many classes we can create in an inner class?  How many classes we can create in an inner class ANS :- Within Main
Inner class
Inner class  when we use inner classed in java
inner class
inner class  what is mean by inner class   Inner class is a non-static class which is defined inside another class
Java nested class example
nested class is declared static. Non-static nested class is also called inner...Java nested class example  Give me any example of Nested Class.   Nested Class: Class defined within another class is called nested class
Inner class
Inner class   //This code doesn't Works// import... { static Inner i; static{ i=new Inner(); } class Inner
Inner Class - Java Beginners
Inner Class  Hi, I have the following question. class Outer{ class Inner{ } public static void main(String[] args) { Outer.Inner inner = new Outer().new Inner(); } } If I compile the above code
Java Nested Class
. Non-static nested classes are called inner classes. It has access to all.... Nested classes are associated with the enclosing class itself, whereas inner classes... class then such a class is called a nested class. Nested classes are a feature
JDBC Nested Resultset
JDBC Nested Resultset       The JDBC Nested Result Set  is the simplest join algorithm. In this case for each tuple in the outer join relation, the entire inner
Inner class
Inner class  how can i call outer class A `s method to print Outer. class A { void m() { System.out.println("outer"); } } public...(); class A { void m() { System.out.println("inner"); } } } class A { void m
nested loops
nested loops  please tell input to get the output: 12345 23456 34567 45678
Nested try
Nested try  Hi, In eclipse without providing input i am getting different outputs ie my exception gets executed first then finally block and vice versa.pl explain me class Demo { static void nestedTry(String args[]) { try
Java inner class
Java inner class  What are inner class and anonymous class
nested for-loop
nested for-loop  hi.write a program that will prompt the user for a positive integer(num) and then display two triangles with num number of lines to represent the following patterns of asterisks. the input num must be validated
 

 

 

DMCA.com