Core Java tutorials.
All the classes in Java are not defined separately from other classes. You can also write one class into another class. The inside class is referred as inner class and the class containing this inner class is called outer class. Inner class is a member of outer class similar to other attributes and methods.
Avoid using inner classes when they are not required. It is hard to maintain and reuse code with inner classes. Only use it when it is required and relevant. They are used usually