yhuJOptionPane.showMessageDialog() method of JOptionPane(class). It has a textbox in which the
user may type in a string (input).
String test=JOptionPane.showInputDialog(“Enter your first integer”);
A input box will appear on the screen asking you to Enter your first integer.
Suspose you type 42 into the text field, when the user presses the OK button, the showInputDialog
method will return with a string of “42”. If you do another input integer of 24 with test2 string, you will
have 42 and 24.
You must convert these string variables into integers in order to do calculations. Therefore, use parse.
*Note: for charAt(), the position starts at 0. It is required to find the character at a specific position in a
s.charAt(0); is H
s.charAt(1); is E
s.charAt(2); is L
Declare a integer variable (mytest) so you can store the int equilvaent of the String (test1) in the
Int mytest= Integer.parseint(test1);
Primitive Type Variables: float numbers, chars, doubles, and integers = literal values
Reference Types: does not actually contain its associated data but contains a reference to the data (the
address of the location where the data is stored in the computer’s memory) = string variables
Objects: can contain more than one piece of data (so it is possible to over write strings and leave one
string with no value which will eventually be collected by the garbage collector)
Strings are a class, and objects are the reference variables
+equals(s1:String) boolean = returns true if this string is equal to string s1
String s1= new String("Welcome");
String s2= "Welcome";
1) if (s1.equals(s2)) //s1 and s2 have the same contents
2) if (s1 == s2) //s1 and s2 have the same reference