Java 方法中,参数的装配顺序
从左到右依次装配,参数的值一旦确定,即使后面修改了该值,方法拿到的值也不会随之变化了。
class Solution {
public int a;
@Override
public String toString() {
return "Solution{" +
"a=" + a +
'}';
}
}
public class Main{
static Solution max;
static Solution change(){
max = new Solution();
max.a = 8;
Solution s = new Solution();
s.a = 5;
return s;
}
public static void method(Solution x,Solution y){
System.out.println(x);
System.out.println(y);
}
public static void main(String[] args) {
max =new Solution();
max.a=0;
method(max,change());
}
}
如需转载,请注明出处
如有侵权,联系删除
2290713181@qq.com
如有侵权,联系删除
2290713181@qq.com