Friday, 3 February 2017

Method : Static Method




public class StaticMethod {

    int i;
    String name;
    static String college="SMU";

    StaticMethod(int i, String name)
    {
    this.i = i;
    this.name = name;
    }
    void display()
    {
        System.out.println("i : "+i+", name : "+name+", college : "+college);
    }
    public static void main(String[] args)
    {
        StaticMethod sm1 = new StaticMethod(1, "ABC");
        sm1.display();
        StaticMethod sm2 = new StaticMethod(2, "MNP");
        sm2.display();
        StaticMethod sm3 = new StaticMethod(3, "XYZ");
        sm3.display();

    }
}

No comments:

Post a Comment