public class T5{
public static void main(
String args[]){
T6 t6_1 = new T6();
T6 t6_2 = new T6();
T6 t6_3 = new T6();
t6_1.test1(t6_2);
t6_1.test2(t6_3.x);
System.out.println(t6_2.x);// prints 20
System.out.println(t6_3.x);// prints 10
}
}
class T6{
int x = 10;
public void test1(T6 tt){
tt.x = 20;
}
public void test2(int y){
y = 30;
}
}
I wonder why the second System.out.println statement does not print 30 like the first System.out.println does.
Can anyone explain it why?
[ April 25, 2006: Message edited by: Chatura Dilan ]