标签:依次 修改 tostring class turn stat print public 方法
从左到右依次装配,参数的值一旦确定,即使后面修改了该值,方法拿到的值也不会随之变化了。
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());
}
}
标签:依次 修改 tostring class turn stat print public 方法
原文地址:https://www.cnblogs.com/ZGQblogs/p/12395047.html