<分区>
我是 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});
}
}