为了账号安全,请及时绑定邮箱和手机立即绑定

我用IntelliJ IDEA赋值,执行时没有输出?

帮忙看一下,为啥输出没有age那些赋值的参数。

public class IniTest1 {
    public static void main(String[] args) {
        Test1 test1=new Test1();
        test1.age=120;
        test1.height=199f;
        test1.name ="Allen";
        test1.eat();
        test1.talk();
    }
}
public class Test1 {
    String name;
    int age;
    float height;
    void talk(){
        System.out.println("You can talk to others");
    }
    void eat(){
        System.out.println("You can eat what you want to ");
    }
}

只输出了以下内容

You can eat what you want to 

You can talk to others


Process finished with exit code 0


正在回答

3 回答

sdfasd

0 回复 有任何疑惑可以回复我~

我找到原因了。

0 回复 有任何疑惑可以回复我~

你的值确实赋给各个参数了,参数值已经是你赋给他的值,但是你并没有print出这些属性值,想要输出的话,可以将这些参数写入printf语句中

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

我用IntelliJ IDEA赋值,执行时没有输出?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号