I am choosing randomly from set of particular strings in my application. I store those data in the code directly. As far as I know, you can't declare public static final String[] = {"aa", "bb"}. So I though the enum would be useful, which works fine with one-word names:
public enum NAMES {
Mike, Peter, Tom, Andy
}
But how do I store sentences like this? Here the enum fails:
public enum SECRETS {
"George Tupou V, the King of Tonga, dies in Hong Kong at the age of 63.",
"Joachim Gauck is elected President of Germany.",
"Lindsey Vonn and Marcel Hirscher win the Alpine Skiing World Cup.";
}
What else should I use? Or am I using the enum incorrectly?
public static final String[] = {"aa", "bb"}": What makes you say that? Aside from the lack of a field-name betweenString[]and=, it looks perfectly correct to me. (Though I think it's better to use an immutable list, e.g.public static final List<String> strings = Collections.unmodifiableList(Arrays.asList("aa", "bb")).) This does not seem to me to be a good use ofenum.