Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Nested classes

 
vi ch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
1. Can anyone tell me if you can have nested classes without the keyword static?
In the book , " Just Java", Fourth Edition, Sun Microsystems, Peter van der Linden gives the following example.

class Hastable{
private Entry []myTable;
//other class variables
static class Entry{
int hash;
\\other variables
}

}
In another class
Hastable.entry he=new hashtable.Entry();
int i=he.hash;
2. My question is the class Hashtable is not a static class. How can it be refenced as a class name, without declaring an object.
Thanks a bunch.
Vidyu
 
Arsho, Ayan
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer to Question 1 :
Yes you can have nested classes without static keyword.
Answer to Question 2 :
Hastable is a Top level class meaning it cannot be declared static.Static classes are referred in the following way
Hastable.entry he=new hashtable.Entry();
similar to a package naming structure.
-Thanks
BTW Your name doesn't follow the standards
somebody is gonna tell u
[ January 17, 2002: Message edited by: Arsho, Ayan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic