File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner class????

 
raymond yadao
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
local class means a class defined within a method !
The following code is illegal !
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic