Ankit Garg wrote:Shaik there is no rule when to use an inner class. It is a matter of situation. Usually you use anonymous classes while doing Event Handling in GUI. Apart from that you might want to keep a related class inside another class. Take an example of Map.Entry in the Java API for that (although Map and Map.Entry are both interfaces but it can be taken as a good example). Since an Entry is related to a Map, so Entry was declared inside Map instead of making it a top level interface...