java final形参_求高手回答final形参问题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

}

public static void newBox(BasicBox myBox){

out.println("Now inside newBox method");

myBox=new BasicBox(60,70,80);

}

public static void makeChanges(int x,BasicBox changeBox){

out.println("Now inside makeChanges method-Doing Changes");

x+=4;

changeBox.length=10;

changeBox.width=20;

changeBox.height=30;

out.println("Variable x="+x);

out.println("Variable changeBox=\n"+changeBox.toString());

out.println("Now leaving makeChanges method");

}

public static void makeChanges_1(final BasicBox changeBox1){

out.println("Now inside makeChanges_1 method-Doing Changes");

changeBox1.length=100;

changeBox1.width=200;

changeBox1.height=300;

out.println("Variable changeBox1=\n"+changeBox1.toString());

out.println("Now leaving makeChanges_1 method");

}

}

运行结果为:

Inside main method

Variable x=5

Variable myBox=

length=2

width=3

height=4

Now inside makeChanges method-Doing Changes

Variable x=9

Variable changeBox=

length=10

width=20

height=30

Now leaving makeChanges method

Now back in the main method

Variable x=5

Variable myBox=

length=10

width=20

height=30

Now inside makeChanges_1 method-Doing Changes

Variable changeBox1=

length=100

width=200

height=300

Now leaving makeChanges_1 method

Now back in the main method

Variable x=5

Variable myBox=

length=100

width=200

height=300

Now inside newBox method

After using the newBox method

Variable myBox=

length=100

width=200

height=300

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值