我是 Java 新手。请问如何在Message Dialog中使用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});
}
}