use of private in getter and setter
1.use of private variable in getter and setter method??
2. how to implement singleton class in another class??
like
public class Singleton {
// class is automatically instantiated when the
// class is loaded
private static Singleton instance = new Singleton()
// constructor is made inaccessible by declaring
// it private
private Singleton() { ... }
// Access to the single instance of the class is
// provided by a static accessor method
public static Singleton getInstance() {
// returns a reference of the private instance
return instance;
}
// rest of the class implementation
}
i have one more class...how to use singleton class inside this???
class B
{
}