class Student
{
//private String name;
private int age;
private static Student s = new Student();
private Student(){}
public static Student getInstance()
{
return s;
}
public void setAge(int age)
{
this.age = age;
}
public int getAge()
{
return age;
}
}
class Single
{
private int num;
private Single(){}
private static Single s = new Single();
public static Single getInstance()
{
return s;
}
public void setNum(int num)
{
this.num = num;
}
public int getNum()
{
return num;
}
}
public class SingleDemo {
public static void main(String[] args)
{
Single s3 = Single.getInstance();
Single s4 = Single.getInstance();
s3.setNum(25);
s4.setNum(30);
System.out.println(s4.getNum());
Student s1 = Student.getInstance();
Student s2 = Student.getInstance();
s1.setAge(20);
s2.setAge(110);
System.out.println(s2.getAge());