wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Inner Class Names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inner Class Names" Watch "Inner Class Names" New topic
Author

Inner Class Names

Craig Oliver
Greenhorn

Joined: Aug 25, 2003
Posts: 21
Is it possible for a regular inner class to have same name as outer class?

Does same rule apply to static inner classes?
Bhushan Damle
Greenhorn

Joined: Nov 28, 2004
Posts: 21
compile following code and see the error
public class InnerClass
{
public void show()
{
System.out.println("Hye-Bye");
}
public static void main(String args[])
{

new InnerClass().show();
class InnerClass
{
public void show()
{
System.out.println("Hello");
}
}

}
}

now compile this code and execute & see the output
public class InnerClass
{
public static void main(String args[])
{

class Inner
{
public void show()
{
System.out.println("Hello");
}
}
new Inner().show();
}

}
Hope, you have got the answer
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inner Class Names