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



Home Answers Viewqa Java-Beginners Java InnerClass

Have Programming Question? Ask it here!
 
 
 


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


How can we use Inner Class in java program?


Advertisement
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
InnerClassExample$InnerClass@19821f

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.



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  different between java & core java
java
java   why iterator in java if we for loop
Java
Java   Whether Java is pure object oriented Language
java
java  explain technologies are used in java now days and structure java
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  write a java program using filenotfoundexception
Java
Java  how to draw class diagrams in java
java
java   difference between class and interface
java
java  why multiple inheritance is not possible in java
java
java  explain object oriented concept in java
java
java  is java purely object oriented language
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
java
java  Write a java code to print "ABABBABCABABBA
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  give a simple example for inheritance in java
java
java  give a simple example for inheritance in java
Java
Java  how to do java in command prompt
java
java  Does java allows multiline comments
java
java  sample code for RARP using java
java
java  RARP implementation using java socket
java
java   What is ?static? keyword
java
java  how can use sleep in java   which book learn of java language
java
java  different between java & core java print("code sample
java
java  how to edit text document by using java then how to edit starting and ending of text document by using java
java
java  hi im new to java plz suggest me how to master java....saifjunaid@gmail.com
java
java  different between java & core java print("code sample
java
java online telephone directory  i need coding for online telephone directory..by using java....pls help me
 

 

 

DMCA.com