java中的参数传递
public class NewArgumentTest {
public Integer i = 0;
public String str = "abc";
class IntAndStr {
Integer i = 1;
String str = "abcd";
public IntAndStr(Integer i1, String str1) {
i = i1;
str = str1;
}
public String toString() {
return "IntAndStr:" + " i:" + i + ", str:" + str;
}
}
public IntAndStr ias = new IntAndStr(i, str);
public void testInt(Integer i) {
i = new Integer(1);
}
public void testStr(String str) {
str = "str";
}
public void testIaS(IntAndStr ias) {
ias = new IntAndStr(2, "abcdr");
}
public static void main(String[] args) {
NewArgumentTest nat = new NewArgumentTest();
nat.testInt(nat.i);
System.out.println("nat.i:"+nat.i);
nat.testStr(nat.str);
System.out.println("nat.str:"+nat.str);
nat.testIaS(nat.ias);
System.out.println("nat.ias:"+nat.ias);
}
}
output:
nat.i:0 nat.str:abc nat.ias:IntAndStr: i:0, str:abc
/** 需要重新整理 **/