gpt4 book ai didi

java - 如何在消息对话框中正确使用命令 "if"?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:39:51 25 4
gpt4 key购买 nike

<分区>

我是 Java 新手。我想问一下如何在消息对话框中使用if

If "age" under 15, add message to new line of Message Dialog-

“你真是宝贝”

我写了这段代码,但出错了。请帮忙。

import javax.swing.JOptionPane;

public class Isim {

public static void main(String[] args) {
// TODO Auto-generated method stub
String name, age, baby;
name = JOptionPane.showInputDialog(null, "Enter Your name");
age = JOptionPane.showInputDialog(null, "Enter Your Age");

int i = new Integer(age).intValue();
baby = "You`re so baby";

JOptionPane.showMessageDialog(null, "Your Name is: "+name+"\n"+"Your Age is: "+age+"\n"+if (i < 15){baby});
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com