1、switch能否作用于byte、long、String上?
可以作用于byte上,不能作用于long上,switch中可以是字符串类型,String(jdk1.7之后可以作用在String上)。
2、扩展总结:
- switch可以作用于:char、byte、short、int
- switch可以作用于:char、byte、short、int 对应的包装类
- switch不可以作用于:long、double、float、boolean,包括它们的包装类
1、switch能否作用于byte、long、String上?
可以作用于byte上,不能作用于long上,switch中可以是字符串类型,String(jdk1.7之后可以作用在String上)。
2、扩展总结: