I have seen both versions, so I'm just wondering, is there any real difference between these two expressions? Which is the conventional way of writing it?
"hello".equals(myString)
myString.equals("hello")
EDIT: This portion of my question makes it not a duplicate
Why is it good that "hello".equals(myString)
doesn't throw an error? Wouldn't you want the caller to be responsible for using a null string? By this logic, wouldn't using myString.equals("hello")
enforce cleaner code?