Friday, December 10, 2010

Accessing Object variable and primitive variable

public static void main(String[] args) {
    test t;
    test s=new test();
    s.y=12;
    t=s;
    s.y++;
    System.out.println(s.y+"\t"+t.y);
    int k,j=12;
    k=j;
    j++;
    System.out.println(k+"\t"+j);

    }
----------------------------------------
OUTPUT
13        13
12        13

No comments:

Post a Comment