Pointer-like behavior in Java
- by Shmoo
I got the following:
class A{
int foo;
}
class B extends A{
public void bar();
}
I got a instance of A and want to convert it to an instance of B without losing the reference to the variable foo.
For example:
A a = new A();
a.foo = 2;
B b = a; <-- what I want to do.
//use b
b.foo = 3;
//a.foo should now be 3
Thanks for any help!