Good point. I was asked myself why they used this construction. Nice answer.
I think it can be changed too.
Antonio Gallardo
> Hi,
>
> Quick question. Why do people put null checks backwards:
>
> if ( null != this.inputSource ) {
>
> IMHO it is harder to read than
>
> if ( this.inputSource != null ) {
>
> and means exactly the same thing.
>
>
> I think this is a throwback from the days of C, where swapping the
> conditions was a handy way to avoid =/== bugs like:
>
> if ( this.inputSource = null ) {
>
> But in Java, the compiler catches this error:
>
> Found 1 semantic error compiling "Test.java":
>
> 10. if (inputSource = null) {
> <---------------->
> *** Error: The type of this expression, "Source", is not boolean.
>
>
> So is there any other reason for this? Can I do a massive grep for
> 'null !=' and change these?
>
>
> --Jeff