praveen kumaar wrote:Don't use static variables and static methods just for getting rid of creating objects.
There is no such thing as code outside a class declaration (well to a first approximation), so you probably mean when would code in a different class create instances? Answer: all the time.If you look in the JLS link I showed you yesterday, it tells you exactly when you can and cannot instantiate a class with private/default access (=package private) constructors.
wayne brandon wrote:. . . When would code outside a class declaration create instances of a class? . . .
wayne brandon wrote:"instantiated from client code" what does that even mean?