Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
522 B
2
Indexable
Never
package singleton;

public class Singleton {
 
    
    private static Singleton instance = new Singleton();
    
    private  Singleton(){};
    
    public static Singleton getinstance(){
        return instance;
    }
            
    public void getmessage(){
        System.out.println("Singleton Class");
    }
}



package singleton;

public class Main {

    public static void main(String[] args) {

    Singleton obj = Singleton.getinstance();
    obj.getmessage();
    }
    
}