RUVIDEO
Поделитесь видео 🙏

Java Programming Tutorial enum Intro

Enum in java is a data type that contains fixed set of constants.
It can be used for days of the week (SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY and SATURDAY) ,
directions (NORTH, SOUTH, EAST and WEST) etc.

The java enum constants are static and final implicitly. It is available from JDK 1.5.

Points to remember for Java Enum

enum improves type safety
enum can be easily used in switch
enum can be traversed
enum can have fields, constructors and methods
enum may implement many interfaces but cannot extend any class because it internally extends Enum class

Enums are lists of constants.
When you need a predefined list of values which do not represent some
kind of numeric or textual data, you should use an enum

You should always use enums when a variable (especially a method parameter) can only take one out of a small set of possible values. Examples would be things like type
constants (contract status: “permanent”, “temp”, “apprentice”), or flags (“execute now”, “defer execution”).

If you use enums instead of integers (or String codes), you increase compile-time checking
and avoid errors from passing in invalid constants, and you document which values are legal to use.

Point-1
All enums implicitly extend java.lang.Enum. Since Java does not support multiple inheritance, an enum cannot extend anything else.

Point-2
Enum in Java are type-safe: Enum has there own name-space. It means your enum will have a type for example “Company” in below example and you can not assign any value other than specified in Enum Constants.

Point-3
You can specify values of enum constants at the creation time. MyEnum.values() returns an array of MyEnum’s values.

Point-4
Enum constants are implicitly static and final and can not be changed once created.

Point-5
Enum can be safely compare using:

Point-6
You can not create instance of enums by using new operator in Java because constructor of Enum in Java can only be private and Enums constants can only be created inside Enums itself.

Point-7
Instance of Enum in Java is created when any Enum constants are first called or referenced in code.

Point-8
An enum specifies a list of constant values assigned to a type.

Point-9
An enum can be declared outside or inside a class, but NOT in a method.

Point-10
An enum declared outside a class must NOT be marked static, final , abstract, protected , or private

Point-11
Enums can contain constructors, methods, variables, and constant class bodies.

Point-12
enum constants can send arguments to the enum constructor, using the syntax BIG(8), where the int literal 8 is passed to the enum constructor.

Point-13
enum constructors can have arguments, and can be overloaded.

Point-14
enum constructors can NEVER be invoked directly in code. They are always called automatically when an enum is initialized.

Point-15
The semicolon at the end of an enum declaration is optional.

These are legal:
enum Foo { ONE, TWO, THREE}
enum Foo { ONE, TWO, THREE};

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java Programming Tutorial enum Intro», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.