以下哪个声明符合 Java 的命名约定?
private boolean writerIsEnabled;
// with methods like
public boolean getWriterIsEnabled()
public void setWriterIsEnabled()
或者
private boolean writerEnabled;
// with methods like
public boolean getWriterEnabled()
public void setWriterEnabled()
我个人认为名字“writerIsEnabled”更具可读性,尤其是当您在这样的 if 语句中使用它时 -
if(writerIsEnabled)
{
//...
}