Java do nothing

后端 未结 6 821
自闭症患者
自闭症患者 2020-12-29 02:16

What is the equivalent to Python\'s pass in Java? I realize that I could use continue or not complete the body of a statement to achieve that effec

6条回答
  •  礼貌的吻别
    2020-12-29 02:40

    There is no (strict) equivalent since in java you have to specify the return type for the method in its declaration which is then checked against a computed type of the following the return statement. So for methods that have a return type - neither semicollon nor leaving empty braces will work;

    I personally use: throw new java.lang.UnsupportedOperationException("Not supported yet."); - this is searchable, alerts you that the method is not implemented and is compatible with the strict return types.

提交回复
热议问题