Java Enums Explained in 6 Minutes

  Рет қаралды 243,703

Coding with John

Coding with John

2 жыл бұрын

All about Enums in Java - Full tutorial with concrete examples.
Enums (short for Enumerations) are used in Java to hold types that have a certain finite set of values. But if you're new to enums, they can be a little confusing. In this Java beginners' tutorial video, we'll talk all about enums - how you can create your own enums, how to use them, and in what situation using an enum makes sense in your code. All in less than 6 minutes!
Learn or improve your Java by watching it being coded live!
Hi, I'm John! I'm a Lead Java Software Engineer and I've been in the programming industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java learners.
Let me know what else you'd like to see!
Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.
📕 THE best book to learn Java, Effective Java by Joshua Bloch
amzn.to/36AfdUu
📕 One of my favorite programming books, Clean Code by Robert Martin
amzn.to/3GTPVhf
🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial
www.audibletrial.com/johnclean...
🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)
bit.ly/3QPNGko
📹Phone I use for recording:
amzn.to/3HepYJu
🎙️Microphone I use (classy, I know):
amzn.to/3AYGdbz
Donate with PayPal (Thank you so much!)
www.paypal.com/donate/?hosted...
☕Complete Java course:
codingwithjohn.thinkific.com/...
codingwithjohn.com

Пікірлер: 228
@ScottishKoala
@ScottishKoala 8 ай бұрын
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!!
@howtomath1245
@howtomath1245 2 жыл бұрын
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 2 жыл бұрын
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 жыл бұрын
@@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 жыл бұрын
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 жыл бұрын
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 2 жыл бұрын
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!!!
@jordhan
@jordhan 2 жыл бұрын
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".
@pranavnyavanandi9710
@pranavnyavanandi9710 Жыл бұрын
Language-agnostic as they say.
@larryd9577
@larryd9577 2 жыл бұрын
The mutability of Enum fields is a nugget of wisdom, which i didn't anticipated. Thanks!
@valoriebroderick
@valoriebroderick Жыл бұрын
These tutorials are amazingly clear and understandable. I'm so grateful because that's not always the case with coding tutorials.
@karlcossaboon7072
@karlcossaboon7072 4 ай бұрын
Ridiculously helpful. As well as short simple and to the point. thanks.
@CodeMonkeyy
@CodeMonkeyy 4 ай бұрын
Your videos are fantastic! Well thought out and prepared. Easy to understand for beginners. Best out here on KZbin
@DaBestOhYeah
@DaBestOhYeah Жыл бұрын
I am so glad that whenever I don't understand something in java, your videos are top on the list!!
@hangyeollee-creuset5108
@hangyeollee-creuset5108 2 жыл бұрын
Love your videos. John. Thank you so much for making the videos. It is pleasure to see you having fun in Java.
@sss_az1063
@sss_az1063 2 жыл бұрын
You’re making my life much easier thank you so much man i really appreciate you
@MrDarshD
@MrDarshD 2 жыл бұрын
Thank you for sharing! Love the names you give to them and also the shortcut tips!
@santuyou1
@santuyou1 2 жыл бұрын
Clear and crisp. Thanks for video. Subscribed.
@faroukmatamir
@faroukmatamir Жыл бұрын
Thank you John, please keep going with new videos and don't stop, I am learning a lot from you....
@remembert0f0rge
@remembert0f0rge 6 ай бұрын
Man your videos are so clear even to me, who can't speak english at all
@Drogo681
@Drogo681 2 жыл бұрын
Straight to the point, and very pedagogical. I have already subscribed, but I like is coming right up.
@micleh
@micleh 2 жыл бұрын
Hi. I've only recently become aware of your KZbin channel, and I wonder why the KZbin 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 Жыл бұрын
you can help by like and subscribe, that boost the youtube algorithm
@mahdinouira3261
@mahdinouira3261 Жыл бұрын
it could be because you are subscribed to many channels, try using two account (it can provide SOME of what you need )
@janfeyen592
@janfeyen592 Жыл бұрын
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
@Habijob
@Habijob Жыл бұрын
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.
@isaacweber7398
@isaacweber7398 2 ай бұрын
Much gooood John. God Bless you! Keep doing that. It's helping me a lot.
@mahodaadikari4116
@mahodaadikari4116 2 жыл бұрын
Another simple and amazing explanation as always. ❤💯
@muhendis_
@muhendis_ 5 ай бұрын
ctrl shift x = this was an awesome knowledge 😄🙏🏻
@seeulater8753
@seeulater8753 6 ай бұрын
Your videos help me a lot. Thank you so much!
@gabrielfono844
@gabrielfono844 Жыл бұрын
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
@jarveyd8660
@jarveyd8660 2 жыл бұрын
You broke it down really well!!
@yogeshvasudevan
@yogeshvasudevan 2 жыл бұрын
Great explanation 👏👏..Thank you for the refresher👍👍🙏
@Coccoutube
@Coccoutube Жыл бұрын
Thanks as always John! My knowledge++
@semilife
@semilife 2 жыл бұрын
Nice on John, short clear and detailed.
@mustapharaimilawal8053
@mustapharaimilawal8053 3 ай бұрын
Great tutorial, as always. Thank you sir.
@122fathom2
@122fathom2 2 жыл бұрын
really short and clear, brilliant.....
@Wilespro1
@Wilespro1 Ай бұрын
Man the greatest tutorial of all time
@HatTrick4030
@HatTrick4030 Жыл бұрын
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
@flaviuvanca9289
@flaviuvanca9289 2 жыл бұрын
Hi John, another nice thing about enums is that you can use abstract methods to customize the constants :)
@jonathanalcantara7347
@jonathanalcantara7347 2 жыл бұрын
Great explanation, thanks!
@codewithankush9753
@codewithankush9753 2 жыл бұрын
Please make Java development full course, they way you explain it's really easy to get understand concept. Thank you
@mikaznavodya7277
@mikaznavodya7277 5 ай бұрын
Thank you, your explanations are very clear ❤
@rishabhshah1218
@rishabhshah1218 2 жыл бұрын
Nice and quick tutorial. Thanks
@ToshiroKiss
@ToshiroKiss Жыл бұрын
Dude, love your channel. saluds from Brazil
@bhaweshpandey4306
@bhaweshpandey4306 2 жыл бұрын
This was helpful 👍, thanks !!
@BunnyboyCarrot
@BunnyboyCarrot Жыл бұрын
Nice and concise, awesome video!
@mashooly_kr7192
@mashooly_kr7192 Жыл бұрын
Thanks it was really helpful!
@OmarMendozaKS
@OmarMendozaKS 2 жыл бұрын
What a heck of explanation man, moreover super creative using cereal, thank you
@jooncco
@jooncco 2 жыл бұрын
Helpful as always
@windz643
@windz643 2 жыл бұрын
I love your way of teaching
@4inchezz199
@4inchezz199 2 жыл бұрын
Thanks man, this actually helped me a lot :D
@withgrowinginsanity198
@withgrowinginsanity198 Жыл бұрын
wow! A gold nuget of information. thanks a lot.
@starry6685
@starry6685 2 жыл бұрын
Thank you for the videos!
@ManhPhuGiang
@ManhPhuGiang Жыл бұрын
Thank you, great video.
@pranavmahajan4190
@pranavmahajan4190 2 жыл бұрын
You are totally awesome. I liked the way you explain
@Imperfectwow
@Imperfectwow 2 жыл бұрын
Great content John thanks
@greatjobbuddy
@greatjobbuddy 2 жыл бұрын
These videos are so great.
@uchihalayan3435
@uchihalayan3435 8 ай бұрын
thank you brother this was helpful
@Devivl
@Devivl Жыл бұрын
Thank you very much, John! 🙂
@pietro-study
@pietro-study 2 жыл бұрын
love ur tutorials! Very quick, u cover most of it and it's fcking understandable!
@hanseuberalles5063
@hanseuberalles5063 Ай бұрын
Loved that! Any tutorial for Strams please ?
@gergelynemeth8244
@gergelynemeth8244 2 жыл бұрын
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?
@chexblu
@chexblu 2 жыл бұрын
How come this has so few views and likes. Excellent video mate, keep it up please!
@kalyankumar8629
@kalyankumar8629 Жыл бұрын
Good toturial Mr.john
@kaykang8808
@kaykang8808 4 ай бұрын
This man makes a boring lesson to a lesson to be a fun and more enjoyable lesson.
@user-gf2jg4df5w
@user-gf2jg4df5w 2 жыл бұрын
Thank you, You are the best.
@navinbusiness2729
@navinbusiness2729 Жыл бұрын
Thanks john it's more useful
@limiakejelu
@limiakejelu 10 ай бұрын
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 👍
@user-zd3iw9ek7r
@user-zd3iw9ek7r 7 ай бұрын
Thanks for your sharing
@DarkenedPossession
@DarkenedPossession 2 жыл бұрын
many thanks dude !!
@Mohamed-uf5jh
@Mohamed-uf5jh 2 жыл бұрын
Thanks, very very clear
@batsybats5591
@batsybats5591 Жыл бұрын
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
@dllm3tommy741
@dllm3tommy741 Жыл бұрын
Thanks for the video
@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!!!!!!!
@mub03
@mub03 9 ай бұрын
Awesome Video!
@KoryGraphic
@KoryGraphic 2 жыл бұрын
This channel is pure trasure
@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!
@Sollace
@Sollace 2 жыл бұрын
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.
@pranavnyavanandi9710
@pranavnyavanandi9710 Жыл бұрын
Impressive bro, really liked your second tip.
@kajimemashiro9686
@kajimemashiro9686 Жыл бұрын
3:40: "plus now there´s more room for my beautiful face, here in the corner" I love you man
@ghettoslick2000
@ghettoslick2000 10 ай бұрын
Awesome Thanks!!!!
@trantrungnghia9642
@trantrungnghia9642 Жыл бұрын
04:48 Sir, your explanation at this point is too good
@aksharjoshi3384
@aksharjoshi3384 2 жыл бұрын
What can I say, you are the best!
@eravil8882
@eravil8882 2 жыл бұрын
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 жыл бұрын
Where do you go to practice java?
@pranavnyavanandi9710
@pranavnyavanandi9710 Жыл бұрын
What do you mean practicing it daily? How are you doing that?
@menaaziz27
@menaaziz27 2 жыл бұрын
I watch all your videos even though I know about the video .. keep it up john!
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Ha, well thank you!
@jvsnyc
@jvsnyc 2 жыл бұрын
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.
@AtulRai
@AtulRai 2 жыл бұрын
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 жыл бұрын
It's a plugin called Darkest Dark
@pranavnyavanandi9710
@pranavnyavanandi9710 Жыл бұрын
@@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.
@philipepompeu
@philipepompeu Жыл бұрын
Great content
@Pacvalham
@Pacvalham 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?
@ayoubmessaoudi5206
@ayoubmessaoudi5206 15 күн бұрын
lovely video dude
@hamidreza8354
@hamidreza8354 2 жыл бұрын
it was great. thanks
@lolcrafter9524
@lolcrafter9524 4 ай бұрын
W video, probably saves me from a negative grade :)
@KH-hn3nu
@KH-hn3nu 11 ай бұрын
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!
@mouadaittalebali3066
@mouadaittalebali3066 2 жыл бұрын
Can not thank you enough!🙏
@Russianspyonyou
@Russianspyonyou 2 жыл бұрын
I learned something!
@lindascoon4652
@lindascoon4652 2 жыл бұрын
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.
@user-ui2hf4vs5f
@user-ui2hf4vs5f 7 ай бұрын
Thank you
@malou5290
@malou5290 2 ай бұрын
excellent!
@pranavnyavanandi9710
@pranavnyavanandi9710 Жыл бұрын
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".
@jakubsz4602
@jakubsz4602 2 жыл бұрын
fantastic!!!!
@DereC519
@DereC519 7 күн бұрын
thank you
@wasimpatel2618
@wasimpatel2618 11 ай бұрын
love you john.
@hulagabal
@hulagabal 2 жыл бұрын
Thanks
@HuwJones
@HuwJones 2 жыл бұрын
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.
@chr215
@chr215 3 ай бұрын
@Coding with John what is the difference between constants and ENUM, in terms of useage and best code practice? Pls share
@gregdawe2786
@gregdawe2786 6 ай бұрын
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!!!
@Metorrite
@Metorrite 3 ай бұрын
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!
@Rockyzach88
@Rockyzach88 Жыл бұрын
So an enum is like a conglomeration of maps or dictionaries for a specific list of things?
Java Anonymous Inner Classes Explained in 6 Minutes
6:27
Coding with John
Рет қаралды 91 М.
Китайка и Пчелка 4 серия😂😆
00:19
KITAYKA
Рет қаралды 3,3 МЛН
Lambda Expressions in Java - Full Simple Tutorial
13:05
Coding with John
Рет қаралды 700 М.
Java. Enum на примерах.
18:34
Sergey Arkhipov Java Tutorials
Рет қаралды 8 М.
Java enum 🪐
10:50
Bro Code
Рет қаралды 61 М.
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1 МЛН
Clean Coding: Das verstehen alle falsch!
12:11
Memory Leek
Рет қаралды 11 М.
Binary Search in Java - Full Simple Coding Tutorial
17:48
Coding with John
Рет қаралды 107 М.
Java Strings are Immutable - Here's What That Actually Means
7:06
Coding with John
Рет қаралды 602 М.