You need to know the differences between primitives and objects in java. When you want to compare value between primitives you can use == operator. while the same case cannot be done with object.
The easiest example in this case is String,
String str1 = new String("value1");// create new...