Posted By

indianocean on 11/13/06


Tagged

enum


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Typesafe Enum pattern


Published in: Java 






URL: http://java.sun.com/developer/technicalArticles/releases/j2se15langfeat/index.html

Expand | Embed | Plain Text
  1. // Up to JDK 1.4
  2. public class TypesafeEnum
  3. {
  4. private final String name;
  5. private TypesafeEnum(String name)
  6. {
  7. this.name = name;
  8. }
  9. public static final TypesafeEnum FILE = new TypesafeEnum("file");
  10. public static final TypesafeEnum EDIT = new TypesafeEnum("edit");
  11. public static final TypesafeEnum FORMAT = new TypesafeEnum("format");
  12. public static final TypesafeEnum VIEW = new TypesafeEnum("view");
  13. public String toString()
  14. {
  15. return name;
  16. }
  17. }
  18.  
  19. // Since JDK 1.5
  20. public enum TypesafeEnum {FILE, EDIT, FORMAT, VIEW};

Report this snippet 

You need to login to post a comment.

Download royalty free graphics