Java 方法中,参数的装配顺序
Posted 断腿三郎
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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());
}
}
以上是关于Java 方法中,参数的装配顺序的主要内容,如果未能解决你的问题,请参考以下文章
15spring注解学习(自动装配)——@Autowired标注在方法构造器和参数位置上