Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JOptionPane

807599Mar 23 2007 — edited Mar 23 2007
I am not sure if it is the location of the brackets for the if, else blocks. I keep getting the else without if error on this one. Any ideas or examples that I could look at to answer my own question. Thanks in advance. I searched the forums but did not find anything that made sense to me yet. This is in NetBeans by the way.

import javax.swing.JOptionPane;
/*
* InputFromKeyboardJOptionPane.java
*
* Created on January 24, 2007, 10:46 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author sang
*/
public class InputFromKeyboardJOptionPaneProject {

/** Creates a new instance of InputFromKeyboardJOptionPane */
public InputFromKeyboardJOptionPaneProject() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String name = "";
name=JOptionPane.showInputDialog("Please enter your name");

String age = "";
age=JOptionPane.showInputDialog("Please enter your age");

if(age > 100){
JOptionPane.showMessageDialog(null, msg);
String msg = "Hello" + name + "You are old!";
}
else
JOptionPane.showMessageDialog(null, msg);
String msg = "Hello" + name + "You are young!";


}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 20 2007
Added on Mar 23 2007
4 comments
316 views