- abstract class Name{
- private Name(){};
- public static final Name ZS = new Name(){
- public Name nextName() {
- return LS;
- }
- };
- public static final Name LS = new Name(){
- public Name nextName() {
- return ZS;//"zhangsan";
- }
- };
-
- public abstract Name nextName();
- public String toString()
- {
- //return this == "ZS" ?"ZS":"LS";-->楼主这里没报错嘛 this=="ZS",Name对象和字符串相等?
- return this == ZS ?"ZS":"LS";
- }
- }
复制代码 |