Share on Google+Share on Google+

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

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

Ads

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
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
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
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
nested loops
nested loops  please tell input to get the output: 12345 23456 34567 45678
Nested Clases
Nested Clases  public class Nestclasses { a obj=new a(); public..."; System.out.println("hellwo in nested class"+i+ch); } } } class Outer..."); } } } /*Q:-Here I innner Class Constructor but its not call why i
Java inner class
Java inner class  What are inner class and anonymous class
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
Tutorials   
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized

Ads

 
Advertisement null

Ads