Advantage of Java inner classes

There are three advantages of inner classes in Java. They are as follows:

Sometimes users need to program a class in such a way so that no other class can access it. Therefore, it would be better if you include it within other classes. If all the class objects are a part of the outer object then it is easier to nest that class inside the outer class. That way all the outer class can access all the objects of the inner class.