Is there an beautiful way to assert pre-conditions in Java methods?

后端 未结 8 2047
慢半拍i
慢半拍i 2021-01-02 02:08

A lot of my functions have a whole load of validation code just below the declarations:

if ( ! (start < end) ) {
    throw new IllegalStateException( \"S         


        
8条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 02:41

    How about assert start < end. Have a look at the documentation.

提交回复
热议问题