Possible Duplicate:
Why is myString.equals(“aString”); different from “aString”.equals(myString);?
why am I seeing "string to compare".equals(input_value) instead of input_value.equals("string to compare") in some java coding?
What are the pros and cons?
Thank you
The results should not be different.
But technically they may.
In first case the equals() and hashCode() methods will be called from the String class.
In the second case the equals() and hashCode() methods will be called from the class of input_value.
Also, if input_value is null, in the first case the result will always be false, where as in the second case you will get a NullPointerException.
It is not enough information to say which one is preffered. It depends on your purpose.
In the first case you avoid NullPointerException.
In the second case you may (if you define the class for input_value) have more control over how you define equality of your objects (equals() and hashCode() methods)