hi all,
Can anyone tell me a real time example for inner classes?

Not sure if that is a homework question or not, but that is a good question. Here is one example I found on the web, it seems legitimate, and it makes a good point that you would not be able to have the same functionality without the inner class. http://www.sbras.ru/win/docs/java/tutorial/java/javaOO/innerclasses.html

The Java tutorials also make a few good points about inner classes in Swing, go down to "Inner classes and Anonymous inner classes" here http://java.sun.com/docs/books/tutorial/uiswing/events/generalrules.html

Page two of this article I found on JavaWorld is particularly interesting as well. It demonstrates why inner classes are useful for programming GUIs, using the simple example that multiple buttons probably have different functionality (for each button), so separating the logic using inner classes might be ideal.
http://www.javaworld.com/javaworld/javaqa/2000-03/02-qa-innerclass.html?page=1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.