in a tutorial (for implementing a xml parser) i saw the following code:
if( \"NODENAME\".equals(xmlreader.getNodeName()) ) { // getNodeName() returns java.l
That saves you from a NullPointerException.
That is Yoda Condition used to solve unsafe null behavior.
In programming jargon, Yoda Conditions (also called Yoda Notation) is a programming style where the two parts of an expression are reversed in a conditional statement.
Advantage is
Swapping the two conditional values does not change the behavior of the program. A common mistake is to accidentally assign a value instead of writing a conditional statement.