i just want to share you what i've learned today.
import java.io.*;
import java.lang.*;
public class singleton
{
static class single_obj
{
static int object = 24;
void inc()
{
object++;
}
void dec()
{
object--;
}
int value()
{
return object;
}
}
public static void main(String args[])
{
System.out.println("\nstatic objects\n");
System.out.println("initial value of object is 24\n");
single_obj instance_1 = new single_obj();
System.out.println("\n\nthe initial value of 1st instance is " +
instance_1.value());
instance_1.inc();
System.out.println("incremented value of 1st instance is " +
instance_1.value());
single_obj instance_2 = new single_obj();
System.out.println("\n\nthe initial value of 2nd instance is " +
instance_2.value());
instance_2.inc();
System.out.println("incremented value of 2nd instance is " +
instance_2.value());
single_obj instance_3 = new single_obj();
System.out.println("\n\nthe initial value of 3rd instance is " +
instance_3.value));
instance_3.dec();
System.out.println("decremented value of 3rd instance is " +
instance_3.value());
System.out.println("\n\n");
}
}