This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need: good example of nested top-level class

 
Hendrik Reimann
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

I'm looking for a good example for nested top-level class
(like described here: http://www.javaworld.com/javaworld/javaqa/1999-08/01-qa-static2.html)

I mean, i understand how it works, but i don't see any use in it. So a usefull example would be nice.

I found this in my algorithms and datastructures book:

class List {
static class Node {
// Code for Node
}
// Code for the List
}

Hendrik
[ April 02, 2006: Message edited by: Hendrik Reimann ]
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of examples from the standard library include Rectangle2D.Double and Rectangle2D.Float
 
Hendrik Reimann
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Garrett

If Sun used this technique, then it should make sense.
I don't have time today to look into that, but i'll do that tomorrow.

Hendrik
 
Tony Morris
Ranch Hand
Posts: 1608
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The term 'nested top-level' class is oxymoronic. The very definition of a nested class is any class that is not a top-level class. In other words, the two a mutually exclusive and do not intersect - not only that, they complete the set of "all classes".

You probably want "nested classes".
http://jqa.tmorris.net/GetQAndA.action?qids=67&showAnswers=true
 
ak pillai
author
Ranch Hand
Posts: 288
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From security perspective inner classes are not advised.

http://www.javaworld.com/javaworld/jw-12-1998/jw-12-securityrules.html


Also from a coding perspective the nested classes are hard to read and maintain. Also
very rarely does it get used. If I were you, would not spend too much effort. It is just good to know, how it is done.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic