|
5/28 |
2004/2/10 [Computer/SW/Languages/Java] UID:29791 Activity:nil 76%like:29789 |
2/10 How come the following prints 1 and 2? If I do a=b, shouldn't they contain equivalent member variables? class A{ int m; public void Main(){ B b; A a; b = new B(); a = b; b.mb(); a.m = 2; System.out.println(b.m); System.out.println(a.m); } } class B extends A{ int m; public void mb(){ m = 1; } } |
5/28 |
|