感谢您的回答。 我试图用void方法改变变量的值。
public void function(int x){
x=x*x;
System.out.println(x);
}
public void main(String args){
int p=5;
System.out.println(p); //The output would be 5.
function(p); //The output would be 25.
System.out.println(p); //The output would be 5, again.
}
通过调用方法,我可以做些什么来改变“p”的值?