Suppose I have four classes in a package named T namely Main, A, B and C
The class Main contains public methods which the classes outside package T access and Main class in turn communicate with other three classes and let some function to happen.
Now I want only a single instance of A, B and C to work in this program, means all are once initialized in class Main and that instances all three classes A,B, and C and used by them.
Previously I created static methods in Main class which returns the required instance of A,B and C to the calling class(A,B,C) but it is creating problems, as I want to that once user stops the function of this package and when he starts it again then the initialization of A,B and C and all fields inside it happens again. Means just like from the beginning.
Any way around for this?