How I can correctly use command "if" in Message Dialog?
I`m new in Java. I would like to ask how I can use "if" in Message Dialog?
If "age" under 15, add message to new line of Message Dialog-
"You`re so baby"
I wrote this codes but it was error.Please help.
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});
}
}
No comments:
Post a Comment