aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inner class???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner class????" Watch "inner class????" New topic
Author

inner class????

raymond yadao
Ranch Hand

Joined: Jan 29, 2001
Posts: 88
according to jls:
It is a compile-time error if a local class declaration contains any one of the following access modifiers: public, protected, private, or static.
public class giant
{

private static class anotherClass
{
int i = 1000;
//System.out.println("this is an inner class");
}
public static void main(String args[])
{
anotherClass antClass = new giant().new anotherClass();
System.out.println(antClass.i);
}
}
why is this code compile and run?
thanks...
raymond
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
local class means a class defined within a method !
The following code is illegal !


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inner class????