#70 Enum Class in Java

Опубликовано: 30 October 2024
на канале: Telusko
60,553
793

Check out our courses:

Enterprise Java Spring Microservices: https://go.telusko.com/enterpriseJava
Coupon: TELUSKO10 (10% Discount)

Master Java Spring Development : https://bit.ly/java-spring-cloud
Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

Java:- https://bit.ly/JavaUdemyTelusko
Spring:- https://bit.ly/SpringUdemyTelusko
Java For Programmers:- https://bit.ly/javaProgrammers

For More Queries WhatsApp or Call on : +919008963671

website : https://courses.telusko.com/
In this lecture we will learn:
Inheritance with the enum
Super class of enum
Enum and Constructor
Object creation in an enum
Important points used in the enum

#1
We can not extend the enum with any other class.
We can define constructors and methods in an enum. Creation of our constructors and variables is also possible in an enum.
We can also define our data types through enum that are known as Enumerated Data Types.
In Java, enum extends the enum class and we get all other methods present inside an enum through the enum class only.
If we print the superclass of an enum class, then it will also return an enum.
Status s= Status.Success;
System.out.println(s.getClass().getSuperclass());
In an enum, every enum constant represents an object of type enum.

#2
Enum and Constructor:
enum contains a constructor and it is executed separately for each enum constant at the time of enum class loading.
We can create a constructor in an enum that can take any parameter, and that value of a parameter might be different in every object of an enum.
Instance variables in an enum are private and we can access them in another class by using getters and setters.
We can print the value of all objects of an enum through a loop and .values() method is used to iterating over all objects.
If any parameterized constructor is present inside an enum, then the default constructor will not be considered.
We create private variables and private constructors in an enum because we use them or create an object for constructors in the same class only.
The constructor in an enum will be called the number of times as much the number of objects created.

Github repo : https://github.com/navinreddy20/Javac...

Java:- https://bit.ly/JavaUdemyTelusko
Spring:- https://bit.ly/SpringUdemyTelusko

More Learning :

Java :- https://bit.ly/3x6rr0N
Python :- https://bit.ly/3GRc7JX
Django :- https://bit.ly/3MmoJK6

JavaScript :- https://bit.ly/3tiAlHo
Node JS :- https://bit.ly/3GT4liq

Rest Api :-https://bit.ly/3MjhZwt
Servlet :- https://bit.ly/3Q7eA7k
Spring Framework :- https://bit.ly/3xi7buh
Design Patterns in Java :- https://bit.ly/3MocXiq
Docker :- https://bit.ly/3xjWzLA

Blockchain Tutorial :- https://bit.ly/3NSbOkc
Corda Tutorial:- https://bit.ly/3thbUKa
Hyperledger Fabric :- https://bit.ly/38RZCRB

NoSQL Tutorial :- https://bit.ly/3aJpRuc
Mysql Tutorial :- https://bit.ly/3thpr4L

Data Structures using Java :- https://bit.ly/3MuJa7S
Git Tutorial :- https://bit.ly/3NXyCPu

Donation:
PayPal Id : navinreddy20
https://www.telusko.com