1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
public class TestTransverValue {
public void changeValue1(int num){ num=1000; }
public void changeValue2(Person person){ person.setName("xxx"); }
public void changeValue3(String str){ str="xxx"; }
public static void main(String[] args) { TestTransverValue test=new TestTransverValue(); int num=20; test.changeValue1(num); System.out.println("num========"+num); Person person=new Person("abc"); test.changeValue2(person); System.out.println("personName======"+person.getName()); String str="abc"; test.changeValue3(str); System.out.println("str===="+str); } }
class Person{ public String name;
public Person(String name) { this.name = name; }
public String getName() { return name; }
public void setName(String name) { this.name = name; } }
|