class OpenSource {
private int x;
public OpenSource(int x) {
this.x = x;
}
public void setX(int x) {
this.x = x;
}
public int getX() {
return x;
}
static OpenSource Open(OpenSource opensource) {
opensource = new OpenSource(100); //line 19
return opensource;
}
public static void main(String a[]) {
OpenSource open = new OpenSource(300); //line 24
System.out.println(open.getX() + ".");
OpenSource opensource = Open(open); //line 26
System.out.println(open.getX() + ".");
System.out.println(opensource.getX() + ".");
open = Open(opensource);
System.out.println(open.getX() + ".");
System.out.println(opensource.getX());
}
}
//why the output produces 300 300 100 100 100 why not 300 100 100 100 100 where i am wrong?
i have drawn representation as below to understand it.