Some additional thoughts:
There are a lot of uses for static and inner member classes, for exactly the reasons that Simon just emphasized. But local classes and anonymous classes? There used to be a lot of uses for anonymous classes. In modern Java, lambdas can often better fulfill the needs that anonymous classes were most often used for. So you may go quite some time without seeing anonymous classes used, depending on what you are doing, and how old the code you're working with is. As for local classes... I very rarely see them, nor want to use them. Especially since I usually have a strong desire to keep my methods short, short enough to easily be seen on a single screen, at least. You may encounter local classes. But you can probably not worry about the details much, as it's unlikely you'll see them much in the real world - other than for certification, if you're doing that.
As an aside: If, in learning about nested and inner classes, you ever encounter the phrase "top-level nested class", be aware that this linguistic travesty was removed from Java almost twenty years ago. It was originally a term for a static nested class. But since about 2005, "top-level" and "nested" are exclusive categories, as they should have been all along.
If you encounter the term now, be aware it's quite outdated, and you should probably move to a newer edition of the book you're using. Or a different tutorial, or article, or whatever. Save yourself from needless confusion.
I sometimes feel as if Java's designers took the initial idea of inner/nested classes and generalized it it "you can declare a class almost anywhere, and we will figure out the consequences of that and write rules to allow you to do so". That's an exaggeration, but I still feel there's some merit to this view. For example, you can declare
a class inside a static method, or a static initializer block. With an anonymous class, you can even declare a class in a static field declaration (as part of the initializer). These are all inner classes, by definition. And yet, there is no enclosing instance
in these cases. So you don't have access to one, and the compiler will complain if you try to access it. So there's an additional category of "inner classes declared in a static context
" which has special rules that are different from what others have described above. More confusion for another special case.