I’ve always used
if ("true".equals(object.getAttribute("someAttr"))) { // ....
because although it is a little more difficult to read it’s much less verbose and I think it’s readable enough so you get used to it very easily
More Related Contents:
- Android, NullPointerException
- Loading resources like images while running project distributed as JAR archive
- NullPointerException in Collectors.toMap with null entry values
- How come invoking a (static) method on a null reference doesn’t throw NullPointerException?
- Java – when to use ‘this’ keyword [duplicate]
- Null check chain vs catching NullPointerException
- Why comparing Integer with int can throw NullPointerException in Java?
- java.lang.NullPointerException is thrown using a method-reference but not a lambda expression
- JavaFX Location is not set error message [duplicate]
- Why does String.valueOf(null) throw a NullPointerException?
- Filter values only if not null using lambda in Java8
- Stand-alone Java code formatter/beautifier/pretty printer? [closed]
- How do you tell if a checkbox is selected in Selenium for Java?
- Android: Pass data(extras) to a fragment
- When is it OK to catch NullPointerException?
- Why does null reference print as “null”
- Why should one use Objects.requireNonNull()?
- Unboxing Null-Object to primitive type results in NullPointerException, fine?
- Why use Optional.of over Optional.ofNullable?
- Is it good practice to use ordinal of enum?
- Java modifiers syntax and format
- Java array, NullPointerException?
- Modifier Keyword order in Java
- For a boolean field, what is the naming convention for its getter/setter?
- Catching nullpointerexception in Java [closed]
- Is concatenating with an empty string to do a string conversion really that bad?
- Should a collection of constants be placed in a class or interface?
- Boolean checking in the ‘if’ condition
- Android: java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String java.lang.Object.toString()’ on a null object reference
- How do I avoid checking for nulls in Java?