lotus

贵有恒何必三更眠五更起 最无益只怕一日曝十日寒

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  1846 随笔 :: 0 文章 :: 109 评论 :: 288万 阅读

package demo.methodparamDemo;

public class MethodParamsDemo {

public static void main(String[] args) {

int num = 10;
changeInt(num);
System.out.println("main:"+num);

boolean flag = true;
changeboolean(flag);
System.out.println("main:"+flag);


Boolean flag2 = true;
changeBoolean(flag2);
System.out.println("main:"+flag2);

String str = "str";
changeString(str);
System.out.println("main:"+str);

Student student = new Student("张三");
changeObj(student);
System.out.println("main:"+student.toString());
}

public static void changeInt(int i){
i = i+1;
System.out.println("method -changeInt:"+i);
}

public static void changeboolean(boolean flag){
flag = false;
System.out.println("method -changeboolean:"+flag);
}


public static void changeString(String str){
str = "new str ";
System.out.println("method -changeString:"+str);
}

public static void changeBoolean(Boolean flag){
flag = false;
System.out.println("method -changeBoolean:"+flag);
}

public static void changeObj(Student student){
student = new Student("李四");
System.out.println("method -changeObj:"+student.toString());
}

}

 

 

 

----------------------------run 

method -changeInt:11
main:10
method -changeboolean:false
main:true
method -changeBoolean:false
main:true
method -changeString:new str
main:str
method -changeObj:李四
main:张三

posted on   白露~  阅读(185)  评论(0编辑  收藏  举报
编辑推荐:
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示