Sorry i interpreted the code like this...my mistake
And thanks a lot for so nice and quick response
public class Fizz {
int x = 5;
public static void main(
String[] args) {
Fizz f1 = new Fizz(); //new object on the heap
Fizz f2 = new Fizz(); //new object on the heap
Fizz f3 = switchFizz(f1, f2); //f3 reference points on f1 object
if(f1 == f3)f2 = f1; //that's true - f3 reference points on f1 object (== checks if there are the same object)
System.out.println((f2 == f3) + " " + (f2.x == f3.x)); //false false - f2 doesn't point on the same object as f3
//f2.x = 6(because there are f1=f3) and f3.x=5;
}
static Fizz switchFizz(Fizz f1, Fizz f2){ //we have the copy of references passing to this method (copy and original //are the same!)
final Fizz z = f1; //OK this is only final reference. There are no final objects!
z.x = 6;
return z; //reference z points on f1
}
}