java-se - This won‘t work?
本文介绍了java-se - This won‘t work?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
这是书的错吗?书说不会运行,但测试能算出来。
解决方案
public class day01{
public static void main(String[] args){
int x = 3;
test(x);// 输出 9
//书上的意思是传入的变量不会改变,因为它是值传递的,你可以打印一下这个x
System.out.println(x);//x == 3
}
public static void test(int x){
x = x * 3;
System.out.println(x);
}
}
这篇关于java-se - This won‘t work?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文