Data Types and Operations 
int n = 1, x = 2;
String s1 = "The value of n = "+n; //  yields a String "The value of n = 1"
String s2 =  "The value of n + x = "+x+y;  // yields a String "The value of n + x = 12"
String s3 =  "The value of n + x = "+(x+y);  // yields a String "The value of n + x = 3"
int x;
double d = 44.2;
x = (int)d;  //  placing (int) before the d tells Java you think you know what you're doing
   double d = 5/6;  //   result is 0.


Examples:

/*
 * declare 3 integers and use them in a simple equation
*/
     int x = 4; // declare x as a 32 bit integer and initialize it to 4
     int y = 100; // declare y as a 32 bit integer and initialize to 100
     int a, b, c; // declare a, b, and c

     b = 2*y;
     c = (int)Math.sqrt(x); // c is now the squareroot of x

     a = (x+y)/c + b;
     a  += (int)Math.pow(b,2);  // set a to itself plus b squared

     c =  a % 2; // c is 0 if a is odd, 1 if a is even
/*
 * some string examples
*/
    String s1 = "Cat";
    String s2 = "rat", s3 = "hampster";
    String s4;

     s4 = s1 + " ate the " + s3;  // concatenates all three strings "Cat ate the hampster"
     s4 =  s2 + 44; // converts 44 to a string and appends it to s2, s4 is now "rat44"
     s4 = ""+ x; // quick way to convert a number to a string, just add it to an empty string


Math class


Integer.parseInt
public static int parseInt(String s)
throws NumberFormatException
Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value. The resulting integer value is returned. Note, leading and trailing spaces cause problems



Parameters:
s - a String containing the int representation to be parsed
Returns:
the integer value represented by the argument in decimal.
example:

int i = Integer.parseInt("33");  // convert the string "33" into the number 33

Double.parseDouble
public static double parseDouble(String s)
throws NumberFormatException
Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value. The resulting integer value is returned. Note, leading and trailing spaces cause problems



Parameters:
s - a String containing the double representation to be parsed
Returns:
the double value represented by the argument in decimal.
example:

double d = Double.parseDouble("33.44");  // convert the string "33.44" into the number 33.44





Some components:

String input = textField.getText();
String input = textField.getText();   // get the text entered by the user
                                      // and store in variable input

int number = 0;
try{
 number = Integer.parseInt(input); // convert text in input into an
                                      // integer stored in number.
}
catch(Exception e)
{
  JOptionPane.showMessageDialog(this,"Invalid data entry");
}

String input = textField.getText();   // get the text entered by the user
                                      //  and store in variable input

double value = 0;
try{
    value = Double.parseDouble(input); // convert text in input into
                                        // an double stored in value.
 }
catch(Exception e)
{
  JOptionPane.showMessageDialog(this,"Invalid data entry");
}
double pi = 3.14;
textField.setText(""+pi);