If you must call bMethod() in you main() method some hacking needs to be done: You can achieve this by making your local inner class implement an interface or inherit from some 'normal' class. This is your example modified to show how this is done:
Joined: Sep 12, 2000
Hi greg philpott, Thanks for your reply. Under what condition we have to write a class inside a method? Can you give some practical examples? What are the advantageous? Thanks, Bala.
Joined: Nov 10, 2000
I do not know of any conditions where a local inner class must be used (a class in a method). I have never had to use one to solve a problem yet, maybe someone with more Swing or AWT experience might have an example for you . . .
Bala/greg, You can use a local inner class if the information you want to the class to represent stays within the method and you don't need it once the method returns. For example, if I have a method that processes records from a database table containing contact information, and this information won't be needed anywhere else, I can create a local inner class to make holding and sorting the records easier. -Peter