- enum Gender
- {
- MAN(),WOMAN{},NONE(){} ;
- private Gender(){}
-
- public String toString()
- {
- String ret = super.toString();
- switch(this)
- {
- case MAN:
- ret = "男";
- break;
-
- case WOMAN:
- ret = "girl";
- break;
-
- default:
- ret = "保密";
- }
- return ret;
- }
- }
复制代码 问题:switch的参数里,为什么能传一个this进去?this是本类对象的引用,具体的引用是怎么指向的?switch不就只能支持那几种基本数据类型和String类型吗?
|