This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Need: good example of nested top-level class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need: good example of nested top-level class" Watch "Need: good example of nested top-level class" New topic

Need: good example of nested top-level class

Hendrik Reimann

Joined: Apr 01, 2006
Posts: 4
Hi everyone

I'm looking for a good example for nested top-level class
(like described here:

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

[ April 02, 2006: Message edited by: Hendrik Reimann ]
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
A couple of examples from the standard library include Rectangle2D.Double and Rectangle2D.Float

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Hendrik Reimann

Joined: Apr 01, 2006
Posts: 4
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.

Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
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".

Tony Morris
Java Q&A (FAQ, Trivia)
ak pillai
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
From security perspective inner classes are not advised.

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.

java j2ee job interview questions with answers | Learn the core concepts and the key areas
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Need: good example of nested top-level class
It's not a secret anymore!