My idea was to create two objects in such a way that when I modified the second object the first one would also be modified. I read that when ussing the assing operator between objects the value of the reference of obj2 is assigned to obj1. I suppose my code doesn't work because it just create a copy of the reference, but I would like to know if there is another way I can do that or if it is impossible.
CODE:
public class Try{
public static void main(String args[]){
Integer a=Integer.valueOf(2);
Integer b;
b=a;
System.out.println(b);
Integer c=Integer.valueOf(3);
a=c;
System.out.println(b);
}
}
Output: 2 2
Desired output: 2 3