代码
package com.java.test;

publicclass T1 {

publicstaticvoid main(String args[]){
String s1
="123";
int t2=333;
T1 t
=new T1();
t.t1(s1);
System.out.println(s1);
t.t3(t2);
System.out.println(String.valueOf(t2));
t.t4(s1);
System.out.println(s1);
t.t5(t2);
System.out.println(String.valueOf(t2));
}

publicvoid t1(String s1){
s1
="haha";
}
publicvoid t3(int t2){
t2
=6666;
}

public String t4(String s1){
s1
="haha";
return s1;
}
publicint t5(int t2){
t2
=6666;
return t2;
}
}

 

 

运行结果:

123
333

123
333

加断点,调试,就可以看到一步一步的运行过程了。得到结果了。

没有变成haha,6666

通过调试,可以知道,参数只在自己的方法里面起作用。

相关文章:

  • 2021-12-15
  • 2021-11-18
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
  • 2023-04-04
  • 2021-10-07
猜你喜欢
  • 2021-12-01
  • 2023-04-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
相关资源
相似解决方案