Hello. pliz tell me how from
public enum Action{ actionFilm1, actionFilm2, actionFilm3, actionFilm4 } Action [] act = Action.values make String [] so that there would be Action data in the array of strings
Thank you in advance
Hello. pliz tell me how from
public enum Action{ actionFilm1, actionFilm2, actionFilm3, actionFilm4 } Action [] act = Action.values make String [] so that there would be Action data in the array of strings
Thank you in advance
for java
public enum Action { actionFilm1, actionFilm2, actionFilm3, actionFilm4; private static final String[] valuesNames = initNames(); private static String[] initNames() { final Action[] states = values(); final String[] names = new String[states.length]; for (int i = 0; i < states.length; i++) { names[i] = states[i].name(); } return names; } public static String[] names() { return valuesNames; } } in the right place, just call Action.names()
If you want to get no names, instead of name() it is better to use toString()
Source: https://ru.stackoverflow.com/questions/416705/
All Articles