The main reason to define inner classes (within a method or a class) is to deal with accessibility of members and variables of the enclosing class and method . An inner class can look up private data members and operate on them. If within a method it can deal with final local variable as well.