Java InnerClass

Ads

 
 

Share on Google+Share on Google+

Naulej kumar
Java InnerClass
1 Answer(s)      4 years and 11 months ago
Posted in : Java Beginners

How can we use Inner Class in java program?

Ads
View Answers

June 15, 2012 at 4:34 PM


public class InnerClassExample{
    class InnerClass{
        String name = "Naulej";     
        @Override
        public String toString() {
            System.out.println(name);
            return super.toString();
        }
    }

    public InnerClassExample(){
        InnerClass innerClass = new InnerClass();
        System.out.println(innerClass.toString());
    }
    public static void main(String[] args){     
        new InnerClassExample();        
    }
}

Output

Naulej
[email protected]

Description:- The above code demonstrates you an Inner Class. An inner class is a class defined inside another class. Here, we have created a class named InnerClassExample and inside it, we have defined another class named InnerClass. Inside this class, we have created a toString method which return the string to its object.


Ads









Related Tutorials/Questions & Answers:
Java InnerClass
Java InnerClass   How can we use Inner Class in java program?   public class InnerClassExample{ class InnerClass{ String name...(); } } public InnerClassExample(){ InnerClass innerClass = new InnerClass
innerclass and database - Java Beginners
innerclass and database  program using innerclass to implement numerical bisection operation to call a procedure to store and update data in a database
Advertisements
Java nested class example
Java nested class example  Give me any example of Nested Class.  ... Class"; //NestedClass instance variable InnerClass innerClass = new InnerClass(); void getOuterS(){ System.out.println(outer); } void
java - Java Interview Questions
java  1.what is the diffrence between length and length()? 2.write aprogram by using static block? 3can interface have an innerclass
SCJP Module-3 Question-8
InnerClass(); } OuterClass() { System.out.print(s); } class InnerClass { String s = "InnerClass"; InnerClass() { System.out.print(s... compile error. 2. Prints : OuterClass InnerClass 3. Prints : OuterClass 4
Java Nested Class
Java Nested Class         In Java programming language, when a class is defined within another... of Java that is included in jdk1.1. The reasons of why we use nested classes
Inner class in java
Inner class in java In this example we will describe inner classes in java.... Inner classes provides an graceful and powerful feature to the Java. Inner...:- This class is defined within a block of Java code so like a local variable
inner class - Java Interview Questions
Java Inner Class  How many classes we can create in an inner class... to the requirement there is no limit . In Java programming language, when a class is defined... are a feature of Java that is included in jdk1.1. The reasons of why we use
Inner Class - Java Beginners
, it will generate two classes, Outer.class & Outer$Inner.class. But If I change the access
SCJP Module-3 Question-2
[] args) { 3 OuterClass.InnerClass i = new OuterClass.new InnerClass(); 4... OuterClass { 8 public int x = 9; 9 public OuterClass() { 10 InnerClass inner = new InnerClass(); 11 inner.innerMethod(); } 12 class InnerClass { 13 public
java
java  diff bt core java and java
java
java  what is java
Java
Java   Whether Java is pure object oriented Language
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
JAVA
JAVA  how the name came for java language as "JAVA
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
Java
Java  how to draw class diagrams in java
java
java  explain object oriented concept in java
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  why to set classpath in java
java
java  give a simple example for inheritance in java
java
java  Does java allows multiline comments
java
java   What is ?static? keyword
java
java  write a java program using filenotfoundexception
java
java   difference between class and interface
Tutorials   
Java Spring Hibernate Struts Training What type of programming language is Java? How do beginners learn about Java? ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017

Ads

 
Advertisement null

Ads