Naming conventions for java methods that return boolean(No question mark)

前端 未结 7 867
深忆病人
深忆病人 2020-12-02 10:49

I like using question mark at the end of method/function names in other languages. Java doesn\'t let me do this. As a workaround how else can I name boolean returning method

相关标签:
7条回答
  • 2020-12-02 11:45

    For methods which may fail, that is you specify boolean as return type, I would use the prefix try:

    if (tryCreateFreshSnapshot())
    {
      // ...
    }
    

    For all other cases use prefixes like is.. has.. was.. can.. allows.. ..

    0 讨论(0)
提交回复
热议问题