Question

I have a XmlPullParser and to set it up I found something useful via google here on StackOverflow on this answer

As I looked through it, I found the line if (null != key) and I am a bit confused because I only know the expression (key != null).

Where is the difference or is it just the same?

Was it helpful?

Solution

They are the same.

The coding style comes from C/C++ where mistakes like

if (variable = value)

are easy to write when

if (variable == value)

was meant. At most a compiler warning is emitted. By consistently writing the r-value first, unintended assignments are avoided since attempting to assign to a r-value is a compile-time error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top