public class Man {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public void man() {
System.out.println("man");
}
}
public class TestMan {
//值传递传递的是值的副本
public static int getInt(int i){
i=4;
return i;
}
//引用传递,传递的是对象的引用,指向的还是原来的对象
public static Man getMan(Man man){
man.setId("111");
return man;
}
public static String getS(String s){
return s="111";
}
public static void main(String[] args) {
int i=1;
TestMan.getInt(i);
System.out.println(i);
Man man = new Man();
man.setId("222");
TestMan.getMan(man);
System.out.println(man.getId());
String s="222";
TestMan.getS(s);
System.out.println(s);
}
}