I see a lot of java code where android prefers to have developers use static inner classes. Particularly for patterns like the ViewHolder Pattern in custom ListAdapters.
I’m not sure what the differences are between static and non-static classes. I’ve read about it but it doesn’t seem to make sense when concerned with performance or memory-footprint.
It’s not just Android developers…
A non-static inner class always keeps an implicit reference to the enclosing object. If you don’t need that reference, all it does is cost memory. Consider this:
When you compile it, what you get will be something like this: