Advertisement
Lokha

Untitled

Jan 3rd, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. public enum MyEnum {
  2. ONE("1"),
  3. TWO("2")
  4. ;
  5.  
  6. private String link;
  7.  
  8. MyEnum(String link) {
  9. this.link = link;
  10. }
  11. }
  12.  
  13. static {
  14. MyEnum[] enums = MyEnum.values();
  15. MyEnum myEnum = null;
  16. for (MyEnum anEnum : enums) {
  17. if (anEnum.name().equalsIgnoreCase("one")) {
  18. myEnum = anEnum;
  19. break;
  20. }
  21. }
  22.  
  23. // мы нашли myEnum по названию "one"
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement