Nested Classes

When to go for nested class? People say that nested classes are more secure. In which way they are more secure than the private members of a class?
[154 byte] By [Suri.ya] at [2007-11-26 16:46:51]
# 1

You can use nested classes for the below reasons:

Logical grouping of classes桰f a class is useful to only one other class, then it is logical to embed it in that class and keep the two together. Nesting such "helper classes" makes their package more streamlined.

Increased encapsulation桟onsider two top-level classes, A and B, where B needs access to members of A that would otherwise be declared private. By hiding class B within class A, A's members can be declared private and B can access them. In addition, B itself can be hidden from the outside world.

More readable, maintainable code桸esting small classes within top-level classes places the code closer to where it is used.

Javeda at 2007-7-8 23:14:18 > top of Java-index,Java Essentials,Java Programming...