File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner classes

 
Ferwed Kondos
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inner classes cannot have static members of any kind? true or false
 
John Stone
Ranch Hand
Posts: 332
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
true - if we consider declaration only
false - if we consider also inheritance (static member can be inherited)
 
Thayarupan Raj
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But We can have static members in "Static Inner class" if enclosing class does not have any static/final member

public class Tests {
public static void main(String args[])
{
}
static class inner
{
static int s=10;
public static void rt()
{

}
}
}


[ September 30, 2007: Message edited by: John Kristin ]
[ September 30, 2007: Message edited by: John Kristin ]
 
Ankith suresh
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi john
But We can have static members in "Static Inner class"
"if enclosing class does not have any static/final member" ???

What does
"if enclosing class does not have any static/final member" ???
meant???
 
John Stone
Ranch Hand
Posts: 332
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from Sun tutorial:


So, when I talked about inner classes, I always meant non-static nested-classes.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic