Hai , could we have classes inside methods, so whenever we call a method so that the other class also gets instantiated and can we use the other class method from the method we call. thanks regards
whew.... not quite sure if I understand the question... but it *sorta* sounds like you're looking for a local class, or an anonymous class These are discussed a lot in the Programmer's Certification Study Forum -- do a quick search in there - I'm sure you'll find some great thread. Check out this one, it seems promising: A class defined within a method
You can have classes inside a method but that class would only exist until the program exited the method. No, the class can continue to exist afterwards - it just can't be referenced as that class from elsewhere in the code. But if a local class implements an interface, you can pass an instance of the local class off to some other object, and the instance can continue to exist, and be referenced as an instance of the interface, long after the method has completed execution.