is there a preformance hit when using enum.values() vs. String arrays?

Posted by Asaf on Stack Overflow See other posts from Stack Overflow or by Asaf
Published on 2010-03-15T09:42:40Z Indexed on 2010/03/15 9:49 UTC
Read the original article Hit count: 388

Filed under:
|
|

i'm using enums to replace String constants in my java app (jre 1.5).

is there a performance hit when i treat the enum as a static array of names, in a method that is called constatnly (e.g. when rendering the UI)?

my code looks a bit like this:

public String getValue(int col) {
  return ColumnValues.values()[col].toString();
}

thanks, asaf :-)

© Stack Overflow or respective owner

Related posts about java

Related posts about enums