Java enum Java tutorial w3Schools Chapter 38 English

Published: 19 July 2022
on channel: w3Schools Tutorials
178
3

Enums
An enum is a special "class" that represents a group of constants (unchangeable variables, like final variables).

To create an enum, use the enum keyword , and separate the constants with a comma. Note that they should be in uppercase letters.

Enum is short for "enumerations", which means "specifically listed".

Enum in a Switch Statement
Enum inside a Class
Loop Through an Enum

Difference between Enums and Classes
An enum can, just like a class, have attributes and methods. The only difference is that enum constants are public, static and final (unchangeable - cannot be overridden).

An enum cannot be used to create objects, and it cannot extend other classes (but it can implement interfaces).

Why And When To Use Enums?
Use enums when you have values that you know aren't going to change, like month days, days, colors, deck of cards, etc.


On this page of the site you can watch the video online Java enum Java tutorial w3Schools Chapter 38 English with a duration of hours minute second in good quality, which was uploaded by the user w3Schools Tutorials 19 July 2022, share the link with friends and acquaintances, this video has already been watched 178 times on youtube and it was liked by 3 viewers. Enjoy your viewing!