public class MainClass { int x = 5; public static void main(String[] args) { final MainClass f1 = new MainClass(); MainClass f2 = new MainClass(); MainClass f3 = MainClassSwitch(f1, f2); System.out.println((f1 == f3) + " " + (f1.x == f3.x)); } static MainClass MainClassSwitch(MainClass x, MainClass y) { final MainClass z = x; z.x = 6; return z; } }