转载自:http://blog.csdn.net/fenglibing/article/details/1753536
1.参数传递
public class T {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "abcd";
int i = 10;
change(str, i);
System.out.println(str);
System.out.println(i);
}
private static void change(String str, int i) {
// TODO Auto-generated method stub
str = "welcome";
i = 20;
}
}
输出:abcd 10
2.for循环的执行顺序:
public class T2 {
static boolean foo(char c) {
System.out.print(c);
return true;
}
public static void main(String[] argv) {
int i = 0;
for (foo('A'); foo('B') && (i < 2); foo('C')) {
i++;
foo('D');
}
}
}
What is the result?
A. ABDCBDCB
B. ABCDABCD
C. Compilation fails.
D. An exception is thrown at runtime.
//
输出结果是:
ABDCBDCB