This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Enum Naming Convention Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Enum Naming Convention" Watch "Enum Naming Convention" New topic

Enum Naming Convention

hemant Budhewar BamniBk
Ranch Hand

Joined: May 09, 2009
Posts: 33
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

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.
public String toString() {
return extension;


Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38036
I agree. Here's the link:
subject: Enum Naming Convention
Similar Threads
Magic number for Microsoft 2007 files
problem in opening office 2007 document in JSP
Excel 2007 and charset getting appended to ContentType response Header
how to check if a docx, xlsx, or pptx file is password protected using apache POI?
XML files to Excel Files