Why is default required for a switch on an enum?

后端 未结 8 2057
礼貌的吻别
礼貌的吻别 2020-11-29 08:46

Normally, default is not necessary in a switch statement. However, in the following situation the code successfully compiles only when I uncomment the default statement. Can

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 09:23

    what happens when xyz is null in your code example? In that case the method is missing a return statement.

提交回复
热议问题