class TestReference{
public static void main(String[] args){
int x=2;
TestReference tr = new TestReference();
System.out.print(x);
tr.change(x);
System.out.print(x);
}
public void change(int num){
num = num +

展开全部
收起
4回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • 火山飞灰

    14人对此回答表示赞同

    System.out.print是不换行的输出,输出了两回2所以是22 , 还有你的你调用的方法是值传递所有数值没有加1,这样写应该就是你要的结果了:
    class TestReference{
    public static void main(String[] args){
    int x=2;
    TestReference tr = new TestReference();
    System.out.println(x);
    x = tr.change(x
    展开
    14
    0回复
    发布于 6年前

    评论(0)

    收起评论

  • Paisley888

    12人对此回答表示赞同

    参数的值传递不会将参数中的值传递给原变量x,所以数值打印出22,望采纳
    展开
    12
    0回复
    发布于 6年前

    评论(0)

    收起评论

  • 爱吃糖的小女孩

    10人对此回答表示赞同

    大哥,你没换行,输出的是两个2啊!
    展开
    10
    0回复
    发布于 6年前

    评论(0)

    收起评论

  • Brooklyn

    5人对此回答表示赞同

    两次输出x,change函数没有改变x的值,因为只是把x的值传进了函数而已。
    展开
    5
    0回复
    发布于 6年前

    评论(0)

    收起评论

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部