从左到右依次装配,参数的值一旦确定,即使后面修改了该值,方法拿到的值也不会随之变化了。

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());
    }
}

相关文章:

  • 2021-09-26
  • 2022-12-23
  • 2021-11-22
  • 2022-01-12
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-12-02
猜你喜欢
  • 2022-12-23
  • 2021-06-10
  • 2021-09-17
  • 2021-10-02
  • 2022-12-23
  • 2022-02-18
相关资源
相似解决方案