Hello people...i'm new to this forum and i'm new to java as well...
Can somebody please tell me what are the differences between an inner class and an outer class??? I found out that inner classes cannot have static declarations. Are there any other significant differences???
inner class is inside another class. I recall private data from the outer class is not available within an inner class but this may not be correct. All data and methods of outer class are availble to inner class. The inner class is not known to other classes. Good way to hide stuff. Outer class knows about it but no other.
The main feature of an inner class is its capability to access even private members of the outer class. Inner classes were included in java, (after many altercated discussions I guess) to enhance inter class ties. There might be a case when your class is specific enough to deserve an entirely new type, but on the other hand, it is tightly coupled with another class. In this condition, inner classes can be used. Though, they have their own limitations. Please refer the documentation on the link specified above.
Inner classes are used primarily to implement helper classes. If you plan on handling user-interface events, you'll need to know about using inner classes because the event-handling mechanism makes extensive use of them.
There are two additional types of inner classes. You can declare an inner class within the body of a method. Such a class is known as a local inner class. You can also declare an inner class within the body of a method without naming it. These classes are known as anonymous inner classes.