Make simple calculations
When comparing actual values use .equals instead of ==

Pay attention to the == java operator, it compares the value of two object references instead of the actual value.

For example your variables are stored in memory like this:

0x000 "string1" //stored in String operator
0x001 "string2" 
0x002 "string3"
0x003 "string1" //stored in String temp
0x004 "string2"
0x005 "string3"


Performing operator == temp translates to "is 0x000 equal to 0x003?", while performing operator.equals(temp) translates to "is 'string1' equal to 'string1' ?"

In other words, use == only if you want to check if two objects are exactly the same objects in the same location in memory