Answer the question
In order to leave comments, you need to log in
How to work with enum in Java?
Reached the topic about transfers. And immediately from the first example some troubles.
An example is given.
enum Apple {
Apple1, Apple2, Apple3, Apple4, Apple5
}
public class App {
public static void main(String[] args) {
Apple apple;
apple = Apple.Apple3;
System.out.println("Значение apple: " + apple);
System.out.println();
apple = Apple.Apple2;
if (apple == Apple.Apple2) {
System.out.println("Переменная apple содержит Apple2.\n");
}
switch(apple) {
case Apple1:
System.out.println("Сорт " + apple);
break;
case Apple2:
System.out.println("Сорт " + apple);
break;
case Apple3:
System.out.println("Сорт " + apple);
break;
case Apple4:
System.out.println("Сорт " + apple);
break;
case Apple5:
System.out.println("Сорт " + apple);
break;
}
}
}
Error:(1, 1) java: enums are not supported in -source 1.3
(use -source 5 or higher to enable enums)
Warning:(3, 12) java: as of release 5, 'enum' is a keyword, and may not be used as an identifier
(use -source 5 or higher to use 'enum' as a keyword)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question