See the following code for an example:
package com.example; public class Sex { public static final Sex MALE = new Sex("M"); public static final Sex FEMALE = new Sex("F"); private String code; private Sex(String code) { this.code = code; } }
If your enumerated type does not provide a {@link java.lang.Object#toString()}method, the enum convertor will use the fully qualified class name, followed by the name of the public static final field referring to each instance, i.e. "com.example.Sex.MALE", "com.example.Sex.FEMALE" and so on.
If you provide a toString() method which returns something different, you should also provide a fromString(String, Locale) method to convert those strings back to instances. @version $Id: EnumType.java 151181 2005-02-03 16:59:31Z tim $
See the following code for an example:
package com.example; public class Sex { public static final Sex MALE = new Sex("M"); public static final Sex FEMALE = new Sex("F"); private String code; private Sex(String code) { this.code = code; } }
If your enumerated type does not provide a {@link java.lang.Object#toString()}method, the enum convertor will use the fully qualified class name, followed by the name of the public static final field referring to each instance, i.e. "com.example.Sex.MALE", "com.example.Sex.FEMALE" and so on.
If you provide a toString() method which returns something different, you should also provide a fromString(String, Locale) method to convert those strings back to instances. @version CVS $Id: EnumType.java,v 1.8 2004/03/09 13:53:54 reinhard Exp $
|
|
|
|
|
|
|
|
|
|