It also must be able to access them directly because the Stack 's public interface supports only LIFO access. This is where inner classes come in. Inner classes are used primarily to implement adapter classes like the one shown in this example. If you plan on handling events from the AWT, then you'll want to know about using adapter classes because the event-handling mechanism in the AWT makes extensive use of them. Anonymous Classes You can declare an inner class without naming it.
Anonymous classes can make code difficult to read.