Planet(int number){ this.number = number; } } public class Main { public static void main(String[] args) { //enum = enumerated (ordered listing of items in a collection) //grouping of constants that behave similarly to objects
Planet myPlanet = Planet.PLUTO;
canILiveHere(myPlanet);
}
static void canILiveHere(Planet myPlanet){
switch(myPlanet) { case EARTH: System.out.println("You can live here :)"); System.out.println("This is planet #"+myPlanet.number); break; default: System.out.println("You can't live here...yet"); System.out.println("This is planet #"+myPlanet.number); break; } }
Practicing... enum Day { MONDAY(1), TUESDAY(2), WEDNESDAY(3), THURSDAY(4), FRIDAY(5), SATURDAY(6), SUNDAY(7); int number; Day(int number){ this.number = number; } } public class Main { public static void main (String[]args) { Day day = Day.MONDAY; workDay (day); } static void workDay (Day day) { switch (day) { case MONDAY: case TUESDAY: case WEDNESDAY: case THURSDAY: case FRIDAY: System.out.println ("It's a working day."); System.out.println("Day number "+day.number); break; default: System.out.println ("It's weekend!"); System.out.println("Day number "+day.number); break; } } }
It's kinda funny how other yters when they talk about concepts, they completely go around about and you just have to bare watching it. I love how I can just watch your video and instantly understand how something works just because you explain it literally at what it is without extra stuff that isn't needed.
I am going through Enums that were introduced in Java 1.5. In Effective Java 2'nd Edition it's mentioned that before Java 1.5 there were int and String enum patterns which were having some deficiencies. I understood the cons of int enum patterns but while going through String enum patterns I got the basic idea but didn't get the deep sense of below statements mentioned under Item30 in Effective Java: This variant, known as the String enum pattern, is even less desirable. While it does provide printable strings for its constants, it can lead to performance problems because it relies on string comparisons. Worse, it can lead naive users to hard-code string constants into client code instead of using field names. If such a hard-coded string constant contains a typographical error, it will escape detection at compile time and result in bugs at runtime. Can anyone help me in understanding what these lines explaining. I would appreciate if it can be explained with some code snippet. Thanks
int number; Fruits(int no){ this.number=no; } } public class EnumEration { public static void main(String[] args) { //enum = enumerated (ordered listing of items in a collection) //grouping of constants that behave similarly to objects
static void iWilleat(Fruits kela) { switch(kela) { case APPLE: System.out.println("I will cut it"); System.out.println("The number is"+kela.number); break; default: System.out.println("I will do any thing rather cutting"); System.out.println("The number is :"+kela.number); break;
enum Planet{
MERCURY(1),
VENUS(2),
EARTH(3),
MARS(4),
JUPITER(5),
SATURN(6),
URANUS(7),
NEPTUNE(8),
PLUTO(9);
int number;
Planet(int number){
this.number = number;
}
}
public class Main {
public static void main(String[] args) {
//enum = enumerated (ordered listing of items in a collection)
//grouping of constants that behave similarly to objects
Planet myPlanet = Planet.PLUTO;
canILiveHere(myPlanet);
}
static void canILiveHere(Planet myPlanet){
switch(myPlanet) {
case EARTH:
System.out.println("You can live here :)");
System.out.println("This is planet #"+myPlanet.number);
break;
default:
System.out.println("You can't live here...yet");
System.out.println("This is planet #"+myPlanet.number);
break;
}
}
}
Very helpful video bro
hi if i wish to random select a enum how do i go about doing that?
make int number final
Practicing...
enum Day
{
MONDAY(1),
TUESDAY(2),
WEDNESDAY(3),
THURSDAY(4),
FRIDAY(5),
SATURDAY(6),
SUNDAY(7);
int number;
Day(int number){
this.number = number;
}
}
public class Main
{
public static void main (String[]args)
{
Day day = Day.MONDAY;
workDay (day);
}
static void workDay (Day day)
{
switch (day)
{
case MONDAY:
case TUESDAY:
case WEDNESDAY:
case THURSDAY:
case FRIDAY:
System.out.println ("It's a working day.");
System.out.println("Day number "+day.number);
break;
default:
System.out.println ("It's weekend!");
System.out.println("Day number "+day.number);
break;
}
}
}
Thank you , my whole village is grateful to you . We watch all your videos together at village center every day if it is not raining
that's awesome! Tell everyone I said hi!
lmfaooo
🤣🤣@@BroCodez
Hah I watch them even when it IS raining
I really like your sense of humor when you teach things, it makes it more fun. Keep it this way!
That "YOURANUS" caught me off-guard lmao, good tutorial btw 👍
Thank you, bro! This was really helpful, especially with a mix of humor in your explanation. I enjoyed watching it while also learning :)
It's kinda funny how other yters when they talk about concepts, they completely go around about and you just have to bare watching it. I love how I can just watch your video and instantly understand how something works just because you explain it literally at what it is without extra stuff that isn't needed.
Thank you for your Java tutorials bro. They are really helpful and easy to understand!
so much struggling with the concept and finally found your video. Thanks man
Your channel is so great, I have never seen a lecture in coding but concise and easy to understand like your videos
enum GalicianWeekday{
LUNS(1),
MARTES(2),
MERCORES(3),
XOVES(4),
VENRES(5),
SABADO(6),
DOMINGO(7);
int number;
GalicianWeekday(int number){
this.number = number;
}
}
well if you consider Australia as a planet then yes, Pluto is a planet too, since its size.equal(Australia)
You are one of the most helpful people on youtube!
thank you so much your videos have been helping me through my college computer science courses!!!!
Man, you are the best. I always watch your videos to learn new languages and you make it really easy. Keep it going 👍🏻👍🏻.
he's officially become the new lord & saviour on java cult😁
thx bruh it's rly helpfull
I feels I really want to be a English native speaker, it’s so important in learning coding
it helps lol
or you know, you can always invent coding in your language
@@ottttoooo but they'd have to make it from a programming language in English
Very true lol. Oh, and Sanskrit would probably help too haha
Best Java tutorials are on this channel! Thanks, Bro!
Thanks for sharing. I like all of your videos.
4:59 THANK YOU VERY MUCH BRO NOW I SOLVE THIS
Your sense of humor just gets me xd
The YOURANUS joke got me haha, your dry humor is quite funny
My first time here, loved the tutorial! I like your humor.
Thank you bro for such a clearly explaining.
enum Planetas {
MERCURIO(1),
VENUS(2),
TERRA(3),
MARTE(4),
JUPITER(5),
SATURNO(6),
URANUS(7),
NEPTUNO(8),
PLUTÃO(9);
int num;
Planetas(int n){
this.num = n;
}
}
public class Main {
public static void main(String[] args) {
//instanciação de enum
Planetas meuPlaneta1 = Planetas.TERRA;
Planetas meuPlaneta2 = Planetas.MARTE;
Planetas meuPlaneta3 = Planetas.NEPTUNO;
Planetas meuPlaneta4 = Planetas.PLUTÃO;
System.out.print("Planeta 1--> ");
habitavel(meuPlaneta1);
System.out.print("Planeta 2--> ");
habitavel(meuPlaneta2);
System.out.print("Planeta 3--> ");
habitavel(meuPlaneta3);
System.out.print("Planeta 4--> ");
habitavel(meuPlaneta4);
}
static void habitavel(Planetas p){
switch (p){
case TERRA:
System.out.println("PODE HABITAR AQUI");
System.out.println("PLANETA #" + p.num);
break;
case MARTE:
System.out.println("Chance de viver aqui");
System.out.println("PLANETA #" + p.num);
break;
default:
System.out.println("Não habitável");
System.out.println("PLANETA #" + p.num);
break;
}
}
}
respect bro
eae mano, ja conseguiu o primeiro emprego com java??
Gracias bro
Great
Thanks for yet another great video. ❤
Bro you are hella funny without even trying
I am going through Enums that were introduced in Java 1.5. In Effective Java 2'nd Edition it's mentioned that before Java 1.5 there were int and String enum patterns which were having some deficiencies.
I understood the cons of int enum patterns but while going through String enum patterns I got the basic idea but didn't get the deep sense of below statements mentioned under Item30 in Effective Java:
This variant, known as the String enum pattern, is even less desirable. While it does provide printable strings for its constants, it can lead to performance problems because it relies on string comparisons. Worse, it can lead naive users to hard-code string constants into client code instead of using field names. If such a hard-coded string constant contains a typographical error, it will escape detection at compile time and result in bugs at runtime.
Can anyone help me in understanding what these lines explaining. I would appreciate if it can be explained with some code snippet.
Thanks
Great intro tutorial to enum.
Appreciate the hard work Bro Code
showing next level is a good idea, thank you bro. Will you upload more videos? what should we do after your videos?
Thanks a lot. What if we wanted to put it in a constructor ? How would that be done? Thanks again.
enum Planet
{
MERCURY(1,"rocky"),
VENUS(2,"rocky"),
EARTH(3,"rocky"),
MARS(4,"rocky"),
JUPITER(5,"gas"),
SATURN(6,"gas"),
URANUS(7,"gas"),
NEPTUNE(8,"gas"),
PLUTO(9,"rocky");
int number;
String planetType;
Planet(int number, String planetType)
{
this.number = number;
this.planetType = planetType;
}
}
Awesome
are enums pretty much objects? are they arrays? or sets?
great content
This video is awesome!!
package enums.java;
enum Fruits{
APPLE(100),MANGO(101),BANANA(102),LEMON(103),KURKURE(104),PUFF(500),PAPER(505);
int number;
Fruits(int no){
this.number=no;
}
}
public class EnumEration {
public static void main(String[] args) {
//enum = enumerated (ordered listing of items in a collection)
//grouping of constants that behave similarly to objects
Fruits myfruit=Fruits.KURKURE;
iWilleat(myfruit);
}
static void iWilleat(Fruits kela) {
switch(kela) {
case APPLE:
System.out.println("I will cut it");
System.out.println("The number is"+kela.number);
break;
default:
System.out.println("I will do any thing rather cutting");
System.out.println("The number is :"+kela.number);
break;
}
}
}
Very good video!
"Come on elon what's taking so long" Oh boy did this age like milk
great
Very good
thank you but how often do we need to use enum.
Perfect as always
thank you , your videos are awesome !
Nice
2:56 I pray musk hear you soon :-)
enum Subjects
{
ENGLISH_LIT,
ENGLISH_LANG,
HINDI,
COMPUTER_SCIENCE,
PHYSICS,
CHEMISTRY,
MATHS;
}
enum Ocean{
PACIFIC(1),
ATLANTIC(2),
ARTIC(3),
INDIC(4),
ANTARTIC(5)
int number;
Ocean (int number){
this.number=number;
}
}
omg very useful to me,thanks :D
Great video!
enum Week{
SUNDAY(0),
MONDAY(1),
TUESDAY(2),
WEDNESDAY(3),
THURSDAY(4),
FRIDAY(5),
SATURDAY(6) ;
int number;
Week(int number){
this.number =number;
}
}
I love how the music of this tutorial is like a minecraft video🤣
enum Color {
RED(1),
GREEN(2),
BLUE(3),
int number;
Color(int number){
this.number = number;
}
}
Thank you for you
cool
Thank you ♡
THANK YOU Bro))))
Dropping a comment.
du hast mich nicht enttäuscht :)
I’ve been on the run for over 4 years now…
thank you so much
public enum Membership {
PLATINUM,
GOLD,
SILVER,
BLUE,
RED;
public String toString(){
switch(this)
{
case PLATINUM:
return "Platinum" ;
case GOLD:
return "Gold";
case SILVER:
return "Silver";
case BLUE:
return "Blue";
case RED:
return "Red";
default:
return "Unknown";
}
}
}
Thank you bro!
Perfect!
Dropping a comment
Thank you
🎉🎉🎉🎉
Thanks
Thanks bro
comment for stats, thanks!
"Youranus" ... I'm dead ^^
Tell me why you are so cool bro
great soundtrack xD
thank you
thank bro
thanks bro!
youtube algorithm prayer
lets deafeat the mighty algorithm
One for the algorithm
thanks gigachad
That sounds like a non mechanical keyboard, I distrut
#defeat the algorithm
Yes bro
"If you don't I'm calling the police" like this line :D
pluto is a planet
Don't call the police buddy
enum Planet{
MERCURY(1),
VENUS(2),
EARTH(3),
MARS(4),
JUPITER(5),
SATURN(6),
NEPTUNE(7),
PLUTO(8);
int number;
Planet(int number){
this.number = number;
}
}
this is for Bro !! :)
Ive been thinking about a constant list but i cant think of one ffs lol guess ima go to jail then ...
run! The police are coming for you!
❤
🌸
Ly bro 4
public enum Gigachad {
MUSCULAR,
SHREDDED,
KNOWS_CODE,
CHISSELED,
IS_NAMED_BRO_CODE,
OVER_9000
}
pls don't call the po po😂
Like!
oh, no, not the police 😬
🤍🤍🤍
come on Elon Musk, whats taking so long ? 🤣🤣
the Third
URANUS