首页 > 编程语言 > 详细

Java 方法中,参数的装配顺序

时间:2020-03-02 14:23:08      阅读:71      评论:0      收藏:0      [点我收藏+]

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

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

Java 方法中,参数的装配顺序

原文:https://www.cnblogs.com/ZGQblogs/p/12395047.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!