#68 What is Enum in Java

  Рет қаралды 134,517

Telusko

Telusko

Күн бұрын

Пікірлер: 21
@arindamkashyap2077
@arindamkashyap2077 10 ай бұрын
🎯 Key Takeaways for quick navigation: 00:00 📚 *Introduction to Enums in Java* - Enums represent a list of constant variables in Java. - They enhance code readability and provide a convenient way to manage related constants. - Enums are not strictly necessary but offer benefits in terms of code organization and clarity. 00:42 🛠️ *Basic Usage of Enums* - Declaring and defining enums inside Java classes. - Accessing enum values and using them in conditional statements. - Common practice includes capitalizing enum values for clarity and consistency. 02:24 🔄 *Utilizing Enum Methods* - Exploring the `values()` method to obtain an array of all enum constants. - Demonstrating how enums can mimic certain class functionalities. - Assigning additional properties to enum constants, enhancing their versatility. 04:34 📊 *Understanding Enum Ordinal* - The `ordinal()` method returns the position of an enum constant in its declaration. - Enum constants are assigned ordinal values based on their declaration order. - Leveraging ordinal values for conditional checks and logical operations. Made with HARPA AI
@sanskartyagi6871
@sanskartyagi6871 Жыл бұрын
Super helpful ! loved the teaching style and your efforts are amazing . Thank you!
@vedantkadu
@vedantkadu Жыл бұрын
coming from your 6 yrs old enum vdo
@amanvikram04
@amanvikram04 6 ай бұрын
Perfect 🙏
@AshiyanaPathan-dh5cw
@AshiyanaPathan-dh5cw 7 ай бұрын
5:43 "ss" nice name ☠☠
@AnkitKumar-ij9sx
@AnkitKumar-ij9sx 7 ай бұрын
Thanks🌟
@alishajarrizvi9070
@alishajarrizvi9070 Жыл бұрын
I don't know why people like you are underrated while the rubbish youtubers are growing exponentially
@GoogleUser-uv9bo
@GoogleUser-uv9bo Жыл бұрын
Bcz of Clickbait Feature. And their entertaining video style(means viewer is watching it passively).
@ravikumark2023
@ravikumark2023 Жыл бұрын
Who said he is underrated 🙄
@laylachisom8996
@laylachisom8996 Ай бұрын
@@ravikumark2023dude makes bank probably
@farhodbekxamidov2013
@farhodbekxamidov2013 11 ай бұрын
👍
@17ashishnandekar89
@17ashishnandekar89 Жыл бұрын
If anyone have solution please tell enum Status { Running, Success, Failed, Interupted; } public class Enum { public static void main(String[] args) { Status[] s = Status.values(); Status s2 = Status.Interupted; System.out.println(s2.ordinal()); for (Status s1 : s) { System.out.println(s1 + " "s1.ordinal()); // here it is showing error that we cannot use ordinal for array } } }
@santhosh-benz7
@santhosh-benz7 Жыл бұрын
You have a compilation error at the print statement, make sure that's correct!
@automobili2801
@automobili2801 Жыл бұрын
System.out.println(s1+" "+s1.ordinal()); try this
@babaritik
@babaritik Жыл бұрын
enum Status { Running, Success, Failed, Interupted; } public class Main { public static void main(String[] args) { Status[] s = Status.values(); Status s2 = Status.Interupted; System.out.println(s2.ordinal()); for (Status s1 : s) { System.out.println(s1 + " "+s1.ordinal()); // here it is showing error because you missed + sign here } } }
@Ovi_93
@Ovi_93 Жыл бұрын
enum Status { Running, Success, Failed, Interupted; } public class Enum { public static void main(String[] args) { Status[] s = Status.values(); Status s2 = Status.Interupted; System.out.println(s2.ordinal()); for (var s1 : s) { System.out.println(s1 + " " + s1.ordinal()); } } }
@MalaBuster
@MalaBuster Жыл бұрын
It seems like you’re trying to print the ordinal value of each element in the Status enum. The error is due to a missing + operator between the string and the ordinal value in the println statement. Here’s the corrected code: Java AI-generated code. Review and use carefully. More info on FAQ. enum Status { Running, Success, Failed, Interupted; } public class Enum { public static void main(String[] args) { Status[] s = Status.values(); Status s2 = Status.Interupted; System.out.println(s2.ordinal()); for (Status s1 : s) { System.out.println(s1 + " " + s1.ordinal()); // added '+' operator } } } In this corrected code, the println statement inside the loop will print each Status enum value followed by its ordinal value. The ordinal() method returns the position of the enum constant in the declaration (where the initial constant is assigned an ordinal of zero). I used Bing chat
#69 Enum if and Switch in Java
3:56
Telusko
Рет қаралды 59 М.
#67 More on Interfaces in Java
3:22
Telusko
Рет қаралды 99 М.
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
#60 Wrapper Class in Java
8:08
Telusko
Рет қаралды 208 М.
How To Actually Achieve Your Goals in 2025 (Evidence-Based)
15:15
How to make Microservices Communicate?
10:24
YourTechBud Codes
Рет қаралды 42 М.
#71 What is Annotation in Java
7:32
Telusko
Рет қаралды 91 М.
#95 Comparator vs Comparable in Java
15:43
Telusko
Рет қаралды 215 М.
#65 What is Interface in Java
8:03
Telusko
Рет қаралды 251 М.
#70 Enum Class in Java
7:55
Telusko
Рет қаралды 66 М.
#53 Packages in Java
12:20
Telusko
Рет қаралды 239 М.
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН