What is the preferred way to write boolean expressions in Java

前端 未结 9 2004
灰色年华
灰色年华 2021-01-18 05:03

I have always written my boolean expressions like this:

if (!isValid) {
  // code
}

But my new employer insists on the following style:

9条回答
  •  悲哀的现实
    2021-01-18 05:24

    I just want to say I learned C twenty years ago in school and have moving onto Perl and Java and now C# which all have the same syntax and...

    I think (!myvar) is the most popular

    I think (myvar==false) is just fine too

    in 20 years i have NEVER EVEN SEEN

    (false==myvar) 
    

    I think your boss is smoking something-- I'm sorry but I'd take this as a sign your boss is some kind of control freak or numbskull.

提交回复
热议问题