• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inner class

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can a static class declared inside a class be called as
inner class?
Please clarify me
Thanks,
senthil
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to your question is yes.

Have you read Getting in Touch with your Inner Class yet?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I tried that link and may have found a mistake in to first part.
This part:
You can also instantiate both the outer class and inner class at the same time:
Inner i = new Outer().new Inner();

Shouldn't that be:
Outer.Inner g = new Outer().new Inner();
I did that and it worked for me. I'm just now learning about Inner Classes. I'm using the Thinking In Java book and I'm really having to struggle. So far, that link you gave makes the most sense. Thank you.
RWS
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! A static inner class is a top level class. You can instansiate this static inner class by using
Code:


<CODE>
public class test{
public static class test1{

public void test1Method(){
System.out.println( "Method in inner static class" );
}

}

public static void main( String args[] ){

test1 t = new test().new test1();
t.test1Method();
/**
* You can altso use test1 t = new test1() because the test1 class is static.
}
}
</code>

 
reply
    Bookmark Topic Watch Topic
  • New Topic