Basic Java Language: Difference between revisions

wikademia>Dmclean
wikademia>Koolaidman
Line 323: Line 323:


=Asking the User=
=Asking the User=
''In order for the following to work properly, you must place the following code on the first line of your .java file. Importing packages will be explained later.''
  import javax.swing.JOptionPane;
Now, let's go on to asking the user to enter a number and doing calculations on it. Basically: <code>JOptionPane.showInputDialog(null, "Hello. Enter something")</code>. Try putting that in a class (in the main method, of course) and run it. Currently, we can't do anything with it because the value is deleted.
Now, let's go on to asking the user to enter a number and doing calculations on it. Basically: <code>JOptionPane.showInputDialog(null, "Hello. Enter something")</code>. Try putting that in a class (in the main method, of course) and run it. Currently, we can't do anything with it because the value is deleted.