java - Duplicate static field (Array vs String) -


i have question following code:

public class settings{  public static final string welcomemessage= "helloworld";  public static final string byemessage= "yo";  public static string[] widgets = {welcomemessage,byemessage};  } 

the compiler complains duplicat variables. can delete 2 separate variables , still acces welcomemessage settings.welcomemessage? don't need acces settings.widget[0]? , possible add variable welcomemessage variable (by instance using static hashtable)?

edit: know code doesn't right it's example because wondered why compiler thinks welcomemessage (as separata variable) same variable in widgets array.

i consider java-enums in case:

public enum settings {     welcomemessage ("helloworld"),     byemessage   ("yo");      public final string value;      settings(string value) {         this.value = value;     } } 

you can access values via settings.welcomemessage.value. list of enums settings.values().


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -