Possible Duplicate:
How do I compare strings in Java?
Why can't my program use my assigned string operator to calculate the two integers? For some reason its as if the program is not accepting the input from the user.
import java.io.*;
public class IntCalc {
public static void main (String [] args) throws IOException {
BufferedReader kb = new BufferedReader (new InputStreamReader (System.in));
System.out.println ("This program performs an integer calculation of your choice.");
System.out.println ("Enter an integer: ");
int x = Integer.parseInt (kb.readLine());
System.out.println ("Enter a second integer: ");
int y = Integer.parseInt (kb.readLine());
System.out.print ("Would you like to find the sum, difference, product, quotient, or remainder of your product?: ");
String operator = kb.readLine();
int finalNum;
if (operator == "sum") {
int finalNum = (x + y);
} else if (operator == "difference") {
int finalNum = (x - y);
} else if (operator == "product") {
int finalNum = (x * y);
} else if (operator == "remainder") {
int finalNum = (x % y);
}
System.out.print ("The " + operator + " of your two integers is " + finalNum ".");
}
}