The Java tutorials explain inner classes (here). After reading that, what didn't you get?
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
They are often used in swing but also in the Collection classes (Iterators). To quote from K&B:
Sometimes, though, you find yourself designing a class where you discover you need behaviour that belongs in a separate, specialized class, but also needs to be intimately tied to the class you're designing
From instance event handlers or iterators.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
In general, you use an inner class if it performs some sort of service for the containing class, and that class alone. You can always make it a separate class in the package, but then it's visible to all other classes in the same package.
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
a bit of art, as a gift, that will fit in a stocking