• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Enum Naming Convention

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I have written an enum, FileExtensions which contains some file extensions ,

I have two ways to write this each extension names,

One way just specifying the lower case


Ex.
enum FileExtensions {
ppt, xls;
}

in this case I just have to get that enum and which will server my purpose, i.e. appending this enum name to file name.


Another way is as below,

please let me know which is the right,


public enum FileExtensions {
PPT("ppt"), PPTX("pptx"), DOC("doc"), DOCX("docx"), XLS("xls"), XLSX("xlsx"),
OK("ok"), ERR("err"), XMl("xml"), TMP("tmp");

// Extenstion used.
private String extension;

FileExtensions(final String extenstion) {
this.extension = extenstion;
}

/**
*
* This is overriden method.
*
* @see java.lang.Enum#toString().
* @return - String.
*/
@Override
public String toString() {
return extension;
}

}



 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
reply
    Bookmark Topic Watch Topic
  • New Topic