-
-
Save vittee/4504167 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
A a = new A(5); | |
System.out.println(a.a); | |
test(a); | |
System.out.println(a.a); | |
} | |
public static void test(A a) { | |
a.a = 3 ; | |
} | |
} | |
class A { | |
private int _a; | |
public A(int value) { | |
this.a = value; | |
} | |
public double a | |
{ | |
get { return _a; } | |
set { _a = value; } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
A a = new A(5); | |
System.out.println(a.getValue()); | |
test(a); | |
System.out.println(a.getValue()); | |
} | |
public static void test(A a) { | |
a.setA(3); | |
} | |
} | |
class A { | |
private int value; | |
public A(int initialValue) { | |
this.value = initialValue; | |
} | |
public void setA(int newValue) { | |
this.value = newValue; | |
} | |
public int getValue() { | |
return this.value; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
int a = 5; | |
System.out.println(a); | |
test(a); | |
System.out.println(a); | |
} | |
public static void test(int a) { | |
a = 3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment