🎯 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 Жыл бұрын
Super helpful ! loved the teaching style and your efforts are amazing . Thank you!
@vedantkadu Жыл бұрын
coming from your 6 yrs old enum vdo
@amanvikram046 ай бұрын
Perfect 🙏
@AshiyanaPathan-dh5cw7 ай бұрын
5:43 "ss" nice name ☠☠
@AnkitKumar-ij9sx7 ай бұрын
Thanks🌟
@alishajarrizvi9070 Жыл бұрын
I don't know why people like you are underrated while the rubbish youtubers are growing exponentially
@GoogleUser-uv9bo Жыл бұрын
Bcz of Clickbait Feature. And their entertaining video style(means viewer is watching it passively).
@ravikumark2023 Жыл бұрын
Who said he is underrated 🙄
@laylachisom8996Ай бұрын
@@ravikumark2023dude makes bank probably
@farhodbekxamidov201311 ай бұрын
👍
@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 Жыл бұрын
You have a compilation error at the print statement, make sure that's correct!
@automobili2801 Жыл бұрын
System.out.println(s1+" "+s1.ordinal()); try this
@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 Жыл бұрын
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 Жыл бұрын
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