What is the preferred way to write boolean expressions in Java

前端 未结 9 2074
灰色年华
灰色年华 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:25

    IMO the first one is much more readable while the second one more verbose.

    I would surely go for the 1st one

提交回复
热议问题