A very poor style to code but sometimes unavoidable.
The second part of that statement is patently false. It is always possible to avoid using nested classes at the implementation level.
I can think of no sensible design reason to nest named classes more than one level, and anonymous classes more than 3 or 4 levels. (I do remember one time using 3 or 4 levels of anonymous inner classes in an Eclipse RCP application with really complicated callbacks. But that was really unusual, and in retrospect it was a bad idea.)
1) is there some limit for nesting classes?
In theory the limit is the 64K limit on fully qualified classnames. In practice, the limit is common sense.
2) are they equivalent?
They? If you are asking if nested classes are equivalent to non-nested classes, the answer is Yes ... to all practical intents. The only thing that you can do with nested classes that you cannot do with regular classes is share things that are declared as private
. And the workaround is to relax your access to package private.
3) how do you deal with such situations? Create library?
I don't know what situation you are talking about. The normal way to modularize a Java programs consisting of multiple classes is to use Java packages rather than class nesting. Is that what you are missing?