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.
  1. M

    Java equals() selection

    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...
Back
Top