Hi Bryan As Far I understand your problem. Your public class and your file name must be the same..
If your pulic class name is "InputFromKeyboardJOptionPane" your file name must be InputFromKeyboardJOptionPane.java On Fri, Nov 27, 2009 at 12:54 PM, R Bryan Irwin <[email protected]> wrote: > I'm sorry about my beginner question but can't seem to find an answer. > In the following code, I have renamed the project in order to send it as > homework. Now, I receive the error 'class InputFromKeyboardJOptionPane is > public, should be declared in a file named > InputFromKeyboardJOptionPane.java'. I have done a clean rebuild and checked > the folder. There is no build file of that name so I don't know what to > refer it to. Any ideas? I think I just don't understand the organization of > the file structure here. > > import javax.swing.JOptionPane; > ~~public class InputFromKeyboardJOptionPane {~~ > > public static void main(String[] args) { > String name = ""; > name=JOptionPane.showInputDialog("Please enter your name"); > String msg = "Hello " +name+ "!"; > JOptionPane.showMessageDialog(null,msg); > String age = ""; > age=JOptionPane.showInputDialog("Please enter your age"); > String msg2 = "You are " +age+ " years old."; > JOptionPane.showMessageDialog(null, msg2); > int ageint = Integer.parseInt(age); > if (ageint > 30){ > JOptionPane.showMessageDialog (null, "You are a little old..."); > } > else { > JOptionPane.showMessageDialog (null, "You are quite young..."); > } > } > } > > -- > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/javaprogrammingwithpassion?hl=en -- --- Public PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xF4CC08C5 -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
