You are using an out of date browser. It may not display this or other websites correctly. You should upgrade or use an alternative browser.
equals
About this tag
The 'equals' tag on WindowsForum.com covers discussions about the Java equals() method, particularly the Yoda condition idiom where a constant string calls .equals() on a variable to avoid null pointer exceptions. Topics include best practices for null-safe string comparison, code readability, and handling null values in Java. The tag is relevant for Java developers working on Windows or cross-platform applications, focusing on common pitfalls and idiomatic solutions.
In Java, if I try to do.equals() on a null string, a null pointer error is issued. I’m wondering whether I can perform the following if I’m attempting to compare if a string is equal to a constant string:
MY CONSTANT STRING.equals(aStringVariable)
I’m sure it’ll work, but is this simply...