Generation

code to explanationSat, 28 Jan 2023

class Foo { public int i = 74; public Foo(int i) { this.i = i; } } ... Foo x = new Foo(92), y = new Foo(35); y = x; y.i = 70; System.out.println(x.i);

The output will be 70 because x and y point to the same object.

Questions about programming?Chat with your personal AI assistant