Java Enums Explained in 6 Minutes

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 239

  • @ScottishKoala
    @ScottishKoala Год назад +66

    How does this man manage to break down these concepts so effectively, especially at such a quick pace?! These videos are a godsend. The way you add a small piece of code then fully explain why you added it and what it does makes the code extremely easy to understand. The humour along with the simple but creative programs is also a huge plus, very engaging. Thank you!!

  • @jordhan
    @jordhan 2 года назад +20

    I was trying to understand Enums in practice to implement in my C# code, but a Java video nailed it for me. Now I understand when my teachers said "learn the idea, not the syntax".

  • @howtomath1245
    @howtomath1245 3 года назад +283

    Can you make a long tutorial about what a junior Java developer should know 100% to pass an interview or cover some core topics about it or a playlist of videos? Your videos are pretty understandable and informative, thank you.

    • @howtomath1245
      @howtomath1245 3 года назад +26

      Because when I look up some vacancies, it’s like you should know almost everything from core to spring and other stuff, it’s pretty hard to concentrate on one particular topic

    • @CallumAtwal
      @CallumAtwal 2 года назад +13

      @@howtomath1245 I'm in the same boat. My approach to it is to ensure I know the core fundamentals fully (beyond what is enough to get by). Hence why I've watched a video on such a simple topic in Java, enums. I've always just used enums in the way hes shown but it certainly helps to re-enforce what you know when you watch to back.
      Doing the same with other trivial and basic java concepts helps strengthen you. As for spring specific things, dummy projects are the way to go. Setting something up yourself. Creating a few difficult scenario's which require spring specific solutions. I work with spring day to day at work but hardly ever will run into edge cases that an interview might ask for.
      Good luck!

    • @TheDecodee
      @TheDecodee 2 года назад +4

      I adhere to the request, your videos have helped me a lot to understand java, but i would really like to see a video about contents that a jr java would need to know to get a job

    • @devilscarrybach8672
      @devilscarrybach8672 2 года назад +2

      I can help you. If you know basic core java then will take 1 week to get ready for job.

    • @TheDecodee
      @TheDecodee 2 года назад

      @@devilscarrybach8672 i would really appreciate your help! How should we do?

  • @AhmedMusrin
    @AhmedMusrin 3 года назад +82

    We had to implement the 2nd part of your video(with grades instead of cereal) as part of my exam(on paper). Without you, I would not have gotten it correct. Thank you!!!

  • @larryd9577
    @larryd9577 2 года назад +6

    The mutability of Enum fields is a nugget of wisdom, which i didn't anticipated. Thanks!

  • @DaBestOhYeah
    @DaBestOhYeah Год назад +2

    I am so glad that whenever I don't understand something in java, your videos are top on the list!!

  • @gabrielfono844
    @gabrielfono844 2 года назад +3

    sir
    thanks so much
    I really appreciate
    I taught myself frontend development two years ago and I got hired recently as backend engineer.
    since I recently started learning java , I was struggling on something on my assignment and this video basically explain everything.
    your example is similar to the problem I have .
    I right away subscribe and will recommend this channel to my friend
    I want to say thank again

  • @juliock-y3w
    @juliock-y3w Год назад +2

    Man your videos are so clear even to me, who can't speak english at all

  • @karlcossaboon7072
    @karlcossaboon7072 9 месяцев назад +2

    Ridiculously helpful. As well as short simple and to the point. thanks.

  • @amitamlani6285
    @amitamlani6285 4 месяца назад +1

    I am trying to improve my proficiency in Java. I found your video very insightful and it allowed me to practice and adapt new coding immediately. I found the enum concept quite difficult to adapt into real usage, whilst looking at numerous other sources. Its application in code is making much better sense now with a strong example.

  • @HatTrick4030
    @HatTrick4030 Год назад +3

    Amazing! now I don't have to watch a 30 minutes of enum video tutorial again on a purchased bootcamp on Udemy. just simple and and understandable. all that matters to us is to understand the syntax of a new lesson and master it and then we can build our projects with details ourselves. the problem with other instructors is that they involve too many peripherals to the main lesson and we understand all except the main topic :D

  • @valoriebroderick
    @valoriebroderick Год назад +2

    These tutorials are amazingly clear and understandable. I'm so grateful because that's not always the case with coding tutorials.

  • @sss_az1063
    @sss_az1063 3 года назад +6

    You’re making my life much easier thank you so much man i really appreciate you

  • @micleh
    @micleh 2 года назад +43

    Hi. I've only recently become aware of your RUclips channel, and I wonder why the RUclips algorithm hasn't recommended your channel earlier.
    I like your succinct videos a lot, and they are superbly suited for my computer science school courses, since Java is the language students learn in higher education in Germany.
    Thanks a lot for the high-quality content.

    • @thalibmuhammad9519
      @thalibmuhammad9519 2 года назад

      you can help by like and subscribe, that boost the youtube algorithm

    • @mahdinouira3261
      @mahdinouira3261 2 года назад

      it could be because you are subscribed to many channels, try using two account (it can provide SOME of what you need )

  • @yourman8808
    @yourman8808 9 месяцев назад

    This man makes a boring lesson to a lesson to be a fun and more enjoyable lesson.

  • @limiakejelu
    @limiakejelu Год назад

    One thing about John is he picks the right examples that makes one watch and never forget the topic….In this case cereals 😂. Good job man 👍

  • @muhendis_
    @muhendis_ 11 месяцев назад +2

    ctrl shift x = this was an awesome knowledge 😄🙏🏻

  • @Wilespro1
    @Wilespro1 6 месяцев назад +1

    Man the greatest tutorial of all time

  • @Habijob
    @Habijob 2 года назад +1

    Bless you and your video(s). I started studying for the OCA and your videos are a big help in understanding the dry text from the book in minutes (literally), haha.

  • @CodeMonkeyy
    @CodeMonkeyy 9 месяцев назад +1

    Your videos are fantastic! Well thought out and prepared. Easy to understand for beginners. Best out here on RUclips

  • @codewithankush9753
    @codewithankush9753 2 года назад +1

    Please make Java development full course, they way you explain it's really easy to get understand concept. Thank you

  • @hangyeollee-creuset5108
    @hangyeollee-creuset5108 2 года назад +4

    Love your videos. John.
    Thank you so much for making the videos.
    It is pleasure to see you having fun in Java.

  • @faroukmatamir
    @faroukmatamir 2 года назад +1

    Thank you John, please keep going with new videos and don't stop, I am learning a lot from you....

  • @HimanshuGupta-jx4nk
    @HimanshuGupta-jx4nk Год назад

    I understood it is more like a class which contains its own instance fields as static. for example class test{ static test monday = new test(); static test tuesday = new test();} Thank you very much!!!!!!!

  • @flaviu-vanca
    @flaviu-vanca 2 года назад +5

    Hi John, another nice thing about enums is that you can use abstract methods to customize the constants :)

  • @122fathom2
    @122fathom2 2 года назад +1

    really short and clear, brilliant.....

  • @Sollace
    @Sollace 2 года назад +11

    1:40 -It's also convention to have one per line, and- (edit: ah you did this later) you don't need the semi-colon if you are not planning on adding any other code to your enum.
    Edit:
    3:09 My understanding is that every time you call Enum#values() it returns a new instance of the array (this is done for security reasons so people can't modify the underlying values array), so as an optimisation you would normally cache this array somewhere if you're going to be using it a lot.

  • @janfeyen592
    @janfeyen592 Год назад +1

    Hey, you may not remember me, but I watched one of your I/O java videos a couple of weeks back and I just wanted to say thanks for the clear straight forward but most importantly amazing Java tutorials you've put out

  • @jarveyd8660
    @jarveyd8660 2 года назад +2

    You broke it down really well!!

  • @santuyou1
    @santuyou1 2 года назад +1

    Clear and crisp. Thanks for video. Subscribed.

  • @MrDarshD
    @MrDarshD 3 года назад +4

    Thank you for sharing! Love the names you give to them and also the shortcut tips!

  • @trantrungnghia9642
    @trantrungnghia9642 Год назад

    04:48 Sir, your explanation at this point is too good

  • @pranavnyavanandi9710
    @pranavnyavanandi9710 2 года назад +2

    final is what makes something constant, and also immutable. If all the fields of a class are made final, then the state of that class is unmodifiable. Which makes the type immutable. At least this is my understanding of it. A handy tip, the data members held by a class/object are what constitute it's "state" and methods make up it's "behavior".

  • @Drogo681
    @Drogo681 2 года назад +1

    Straight to the point, and very pedagogical. I have already subscribed, but I like is coming right up.

  • @eravil8882
    @eravil8882 3 года назад +9

    Hi sir, I've finished the core of java and I am now practicing it daily, and I started to explore more on advanced level and I'm going to start it in java enums. Thank u sir for sharing this. I'm really looking forward for your future videos about java. New Subscriber here!

    • @jetspray3
      @jetspray3 2 года назад +1

      Where do you go to practice java?

    • @pranavnyavanandi9710
      @pranavnyavanandi9710 2 года назад

      What do you mean practicing it daily? How are you doing that?

  • @chexblu
    @chexblu 3 года назад +1

    How come this has so few views and likes. Excellent video mate, keep it up please!

  • @semilife
    @semilife 2 года назад +1

    Nice on John, short clear and detailed.

  • @Coccoutube
    @Coccoutube 2 года назад +1

    Thanks as always John!
    My knowledge++

  • @OmarMendozaKS
    @OmarMendozaKS 2 года назад +1

    What a heck of explanation man, moreover super creative using cereal, thank you

  • @HuwJones
    @HuwJones 2 года назад +1

    Something missing here is the importance or ordinality. As in most other languages implementing enums or ordinals the items in the enumeration have an ordinal value...the order in which the enumeration's items are defined IS SIGNIFICANT. This can create problems in a project if developers try to re-order the items later on...something which should not be done. This idea of ordinality also has repercussions when mapping to a database. Most databases map enums to a column using the ordinal value by default. Just don't forget the ordinality.

  • @batsybats5591
    @batsybats5591 2 года назад

    Tysm for this video! I had watched another video on enums, but somehow errors were being thrown in my program and I didn't understand the purpose of enums, nor how to use them and now I think I have a clear basic understanding of them. Plus, I really want some cereals now lol

  • @AtulPal-i5s
    @AtulPal-i5s 2 месяца назад

    Such an amazing explanations with very good examples. Thanks

  • @KoryGraphic
    @KoryGraphic 2 года назад

    This channel is pure trasure

  • @windz643
    @windz643 2 года назад

    I love your way of teaching

  • @greatjobbuddy
    @greatjobbuddy 2 года назад +1

    These videos are so great.

  • @mahodaadikari4116
    @mahodaadikari4116 2 года назад +1

    Another simple and amazing explanation as always. ❤💯

  • @yogeshvasudevan
    @yogeshvasudevan 2 года назад +1

    Great explanation 👏👏..Thank you for the refresher👍👍🙏

  • @menaaziz27
    @menaaziz27 3 года назад +1

    I watch all your videos even though I know about the video .. keep it up john!

    • @CodingWithJohn
      @CodingWithJohn  3 года назад

      Ha, well thank you!

    • @jvsnyc
      @jvsnyc 3 года назад +1

      Me too. I love seeing how he describes it in such a short time without saying anything flat-out wrong which would be so easy to do when trying to make really short videos.

  • @isaacweber7398
    @isaacweber7398 8 месяцев назад

    Much gooood John. God Bless you! Keep doing that. It's helping me a lot.

  • @kajimemashiro9686
    @kajimemashiro9686 2 года назад

    3:40: "plus now there´s more room for my beautiful face, here in the corner" I love you man

  • @seeulater8753
    @seeulater8753 11 месяцев назад

    Your videos help me a lot. Thank you so much!

  • @jonathanalcantara7347
    @jonathanalcantara7347 2 года назад +1

    Great explanation, thanks!

  • @mustapharaimilawal8053
    @mustapharaimilawal8053 8 месяцев назад

    Great tutorial, as always. Thank you sir.

  • @jooncco
    @jooncco 2 года назад +1

    Helpful as always

  • @Devivl
    @Devivl 2 года назад

    Thank you very much, John! 🙂

  • @pranavmahajan4190
    @pranavmahajan4190 2 года назад +1

    You are totally awesome. I liked the way you explain

  • @bhaweshpandey4306
    @bhaweshpandey4306 3 года назад +2

    This was helpful 👍, thanks !!

  • @hansmalm2801
    @hansmalm2801 2 месяца назад +1

    The level of humor here is 108.

  • @rishabhshah1218
    @rishabhshah1218 2 года назад

    Nice and quick tutorial. Thanks

  • @mikaznavodya7277
    @mikaznavodya7277 11 месяцев назад

    Thank you, your explanations are very clear ❤

  • @karyoplasma
    @karyoplasma 2 года назад +1

    OK, I'm just gonna confess my sin: I dev'd with Java for a very long time and I still sometimes use enums for stuff I should better be using a database. They are just so handy. Screw the inefficiency large enums create because of overhead, I wanna make life easy for me and I like switch statements lol

  • @Metorrite
    @Metorrite 9 месяцев назад

    4:32 - You thought we would not notice, but we did :)
    Real question, what design pattern do you use when you have enums that are constant values that need to contain a field that is an object whose internal values need to be changed across instances? For example, if you have different kinds of web input fields in an enum, and you know for certain the type of data type each field returns (String, int, boolean, array, etc) so you want to assign a corresponding validation strategy to each, however, in the strategy maybe you want to validate different values against the result across different input fields of the same type. This is my particular problem however i hope this represents the underlying design question i have!

  • @ToshiroKiss
    @ToshiroKiss Год назад

    Dude, love your channel. saluds from Brazil

  • @hanseuberalles5063
    @hanseuberalles5063 6 месяцев назад

    Loved that! Any tutorial for Strams please ?

  • @عبدالرحمانعبدو-ف9س
    @عبدالرحمانعبدو-ف9س 3 года назад +1

    Thank you, You are the best.

  • @pietro-study
    @pietro-study 3 года назад

    love ur tutorials! Very quick, u cover most of it and it's fcking understandable!

  • @withgrowinginsanity198
    @withgrowinginsanity198 2 года назад

    wow! A gold nuget of information. thanks a lot.

  • @Cablur
    @Cablur Год назад

    Ohh, I really like your sense of humor and how you explain things, even though it was a bit fast. But maybe I'm just tired^^
    Anyways, thank you for this great video!

  • @BunnyboyCarrot
    @BunnyboyCarrot 2 года назад

    Nice and concise, awesome video!

  • @AtulRai
    @AtulRai 2 года назад +4

    Hey John, thank you for sharing your experience. I have watched couple of videos and became the fan of your explanation.
    If you don't mind, may I know which theme you are using in your Eclipse IDE?
    it's looking cool.

    • @CodingWithJohn
      @CodingWithJohn  2 года назад +3

      It's a plugin called Darkest Dark

    • @pranavnyavanandi9710
      @pranavnyavanandi9710 2 года назад +1

      @@CodingWithJohn Hello John. Could you make a video covering these things in eclipse like Maven, gradle, ant build, mylyn etc. ? Would be quite informative for beginners. Eclipse tends to overwhelm you with all these terms sometimes.

  • @starry6685
    @starry6685 3 года назад +1

    Thank you for the videos!

  • @aksharjoshi3384
    @aksharjoshi3384 3 года назад

    What can I say, you are the best!

  • @Imperfectwow
    @Imperfectwow 2 года назад +1

    Great content John thanks

  • @4inchezz199
    @4inchezz199 2 года назад

    Thanks man, this actually helped me a lot :D

  • @lolcrafter9524
    @lolcrafter9524 10 месяцев назад

    W video, probably saves me from a negative grade :)

  • @kalyankumar8629
    @kalyankumar8629 2 года назад

    Good toturial Mr.john

  • @uchihalayan3435
    @uchihalayan3435 Год назад

    thank you brother this was helpful

  • @KH-hn3nu
    @KH-hn3nu Год назад

    Amazing break down John, thank you!... Now if only we can get you to reassess these gradings for deliciousness. Captain Crunch is 110/100 LOL!

  • @benR55565
    @benR55565 3 года назад

    You dont have nearly as much views as you should have. thank you!

  • @Pacvalham
    @Pacvalham 2 года назад +2

    1:17 IntelliJ tells me that the semicolon is unnecessary, and the enum compiles with or without it; was it required in an earlier version of Java?

  • @mashooly_kr7192
    @mashooly_kr7192 Год назад

    Thanks it was really helpful!

  • @mouadaittalebali3066
    @mouadaittalebali3066 2 года назад +1

    Can not thank you enough!🙏

  • @navinbusiness2729
    @navinbusiness2729 2 года назад

    Thanks john it's more useful

  • @gregdawe2786
    @gregdawe2786 Год назад

    Holy broken sewer pipe batman, thank you. I've been trying to figure out how to use enums for the past few hours. THANK YOU!!!

  • @aligooya8514
    @aligooya8514 2 года назад

    You are born a teacher! did you know that?

  • @jvsnyc
    @jvsnyc 3 года назад

    It isn't my style to create methods for the enum values, however, I have worked with developers who absolutely loved that and went to town with it. It is also on the Oracle Certification Exams. So even here, there is room for a follow up video "Fancy Enum tricks". You might also mention that from Ancient Java there used to be something actually called an Enumeration, which was more like a primitive pre-collections-framework Iterator than an actual enum, which came quite late to the party in Java. If you look at enough old API's or old code, you will see them. I disapprove of teaching all about them, they are obsolete, but just mentioning that there's this old thing out there called an Enumeration, don't worry about it but don't confuse them, well, probably that is cool.

    • @CodingWithJohn
      @CodingWithJohn  3 года назад +1

      Yep, I've had to do some wacky things with enums from time to time, some of which involved methods that did things like loop through all values looking for one of its fields matching a certain value. They have their place, but you might have even crazier things that you're thinking of.
      I'm young enough that I was introduced to Java after enums were already introduced, so I never had to deal with them not being around. So I'll have to check out that Enumeration type!

    • @jvsnyc
      @jvsnyc 3 года назад

      @@CodingWithJohn I didn't take Java seriously back then, because I was still a C snob "C is a Real Programming Language, because it emits highly optimized machine code, not some bytecode for an interpreter!" Of course, back then, saying that didn't sound as dumb as it might come across now, Java has "come a long way, baby!" in delivering optimized code at runtime.

    • @jvsnyc
      @jvsnyc 3 года назад

      @@CodingWithJohn Yeah, basically this dude would create a compile-time fixed "family" of related types, like an inheritance hierarchy, but closed and fixed rather than extensible. I haven't seen that pattern used much outside of that one job, but boy did he go to town with it!

    • @rorymax
      @rorymax 2 года назад

      Plural enum names makes very little sense. If you declare a local variable to hold a value from that enum, it’ll look like
      DaysOfWeek currentDay;
      Now that really makes no sense. All an enum is is a class, and each value you declare in an enum is an instance of that class. So the name of your enum should reflect what the values are. Each value if a DayOfWeek. So that’s what the enum should be called. That’s why I clicked on this video, the thumbnail annoyed me into clicking

  • @ManhPhuGiang
    @ManhPhuGiang Год назад

    Thank you, great video.

  • @lindascoon4652
    @lindascoon4652 2 года назад +1

    Thank you for your videos. Could you make some videos on a common java frameworks like springboot, gradle, maven etc. I can code in java now but it's like a completely new language when you have to use frameworks.

  • @David-hl1wo
    @David-hl1wo 2 года назад +29

    Very controversial video.

  • @MarkWesley
    @MarkWesley Год назад

    50/50 mix of Reese's Puffs and Cocoa Puffs for the win!

    • @CodingWithJohn
      @CodingWithJohn  Год назад +1

      This is an interesting proposal. But doesn't that just dilute the peanut-butteriness of the cereal by adding additional chocolate to the already existing perfect mix of peanut butter and chocolate that is the Reese's Puff's recipe?

    • @MarkWesley
      @MarkWesley Год назад

      @@CodingWithJohn Excellent point. 😃

  • @anitaliberatore2272
    @anitaliberatore2272 2 года назад +1

    can you do a video about dependency injection?

  • @gergelynemeth8244
    @gergelynemeth8244 2 года назад +1

    Hey Jon, great video as always, love the way you explain things, makes it very easy to learn. Currently I'm working on a shift/rota planning cli app, just to practice several topics at the same time. I have some methods which return the days of current week and coming week as a list just to make it easier/faster to select the desired day to plan. My question would be: is it possible to use these methods dynamically to assign the dates to the enum values(mon-sun) every time the app is run? If so what would be a good way to do that?

  • @ThuYeinSoe-c7d
    @ThuYeinSoe-c7d Год назад

    Thanks for your sharing

  • @ousmanetall1286
    @ousmanetall1286 11 месяцев назад

    All this programming stuffs make me have a headache, but anyway it's fun!

  • @Mohamed-uf5jh
    @Mohamed-uf5jh 2 года назад

    Thanks, very very clear

  • @Hughsie28
    @Hughsie28 2 года назад +5

    Surprised you didn't include the abstract methods in the ENUM's as another way to give them more features, ie:
    public enum Test {
    MY_VALUE_NAME {
    public String myReadableValue() {
    return "My Value Name!";
    }
    };
    public abstract String myReadableValue();
    }
    usage:
    Test.MY_VALUE_NAME.myReadableValue();
    Output:
    "My Value Name!"

  • @CRII1P1
    @CRII1P1 3 года назад +1

    Can you do a video on Stacks and Queues please

  • @dllm3tommy741
    @dllm3tommy741 Год назад

    Thanks for the video

  • @DarkenedPossession
    @DarkenedPossession 2 года назад

    many thanks dude !!

  • @javabounding
    @javabounding Год назад

    Thank you