Не возможно создать публичный конструктор в Enum
public enum Size {
VERY_SMALL("XS"), SMALL("S"), AVARAGE("M"), BIG("X"), VERY_BIG("XL");
Size(String abbreviation) {
this.abbrevation = abbreviation;
}
private String abbrevation;
public String getAbbrevation() {
return abbrevation;
}
}
Size s = Size.VERY_SMALL;
System.out.println(s.getAbbrevation());
System.out.println(s);
Size s1 =Size.valueOf("BIG");
System.out.println(s1);
Size[] values = Size.values();
for (Size str: values ) {
System.out.println(str);
}
switch (size){
case BIG:case VERY_BIG:
System.out.println("Wof - wof");
break;
case AVARAGE:
System.out.println("Raf - raf");
break;
case SMALL: case VERY_SMALL:
System.out.println("Tyaf - tyaf");
break;
}
public enum Size {
VERY_SMALL("XS"), SMALL("S"), AVARAGE("M"), BIG("X"), VERY_BIG("XL");
Size(String abbreviation) {
this.abbrevation = abbreviation;
}
private String abbrevation;
public String getAbbrevation() {
return abbrevation;
}
}
Size s = Size.VERY_SMALL;
System.out.println(s.getAbbrevation());
System.out.println(s);
Size s1 =Size.valueOf("BIG");
System.out.println(s1);
Size[] values = Size.values();
for (Size str: values ) {
System.out.println(str);
}
switch (size){
case BIG:case VERY_BIG:
System.out.println("Wof - wof");
break;
case AVARAGE:
System.out.println("Raf - raf");
break;
case SMALL: case VERY_SMALL:
System.out.println("Tyaf - tyaf");
break;
}
Комментариев нет:
Отправить комментарий