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.
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;
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
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
That "YOURANUS" caught me off-guard lmao, good tutorial btw 👍
I really like your sense of humor when you teach things, it makes it more fun. Keep it this way!
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, bro! This was really helpful, especially with a mix of humor in your explanation. I enjoyed watching it while also learning :)
so much struggling with the concept and finally found your video. Thanks man
Thank you for your Java tutorials bro. They are really helpful and easy to understand!
well if you consider Australia as a planet then yes, Pluto is a planet too, since its size.equal(Australia)
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;
}
}
thank you so much your videos have been helping me through my college computer science courses!!!!
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
You are one of the most helpful people on youtube!
Man, you are the best. I always watch your videos to learn new languages and you make it really easy. Keep it going 👍🏻👍🏻.
Best Java tutorials are on this channel! Thanks, Bro!
Your sense of humor just gets me xd
Thanks for sharing. I like all of your videos.
The YOURANUS joke got me haha, your dry humor is quite funny
Thank you bro for such a clearly explaining.
My first time here, loved the tutorial! I like your humor.
4:59 THANK YOU VERY MUCH BRO NOW I SOLVE THIS
Great
Gracias bro
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??
Thanks for yet another great video. ❤
Very good video!
Perfect as always
Great intro tutorial to enum.
great
Bro you are hella funny without even trying
great content
Nice
"Come on elon what's taking so long" Oh boy did this age like milk
Awesome
Appreciate the hard work Bro Code
Very good
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;
}
}
}
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;
}
}
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
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.
This video is awesome!!
2:56 I pray musk hear you soon :-)
Thank you for you
Great video!
thank you but how often do we need to use enum.
are enums pretty much objects? are they arrays? or sets?
thank you , your videos are awesome !
enum Subjects
{
ENGLISH_LIT,
ENGLISH_LANG,
HINDI,
COMPUTER_SCIENCE,
PHYSICS,
CHEMISTRY,
MATHS;
}
cool
omg very useful to me,thanks :D
THANK YOU Bro))))
Perfect!
I love how the music of this tutorial is like a minecraft video🤣
du hast mich nicht enttäuscht :)
Thanks
enum Ocean{
PACIFIC(1),
ATLANTIC(2),
ARTIC(3),
INDIC(4),
ANTARTIC(5)
int number;
Ocean (int number){
this.number=number;
}
}
Thank you
Dropping a comment.
Thank you bro!
Thank you ♡
thank you
thank you so much
enum Week{
SUNDAY(0),
MONDAY(1),
TUESDAY(2),
WEDNESDAY(3),
THURSDAY(4),
FRIDAY(5),
SATURDAY(6) ;
int number;
Week(int number){
this.number =number;
}
}
Dropping a comment
enum Color {
RED(1),
GREEN(2),
BLUE(3),
int number;
Color(int number){
this.number = number;
}
}
Thanks bro
🎉🎉🎉🎉
great soundtrack xD
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";
}
}
}
thanks bro!
Yes bro
thanks gigachad
thank bro
Tell me why you are so cool bro
I’ve been on the run for over 4 years now…
"Youranus" ... I'm dead ^^
Ly bro 4
One for the algorithm
Like!
❤
comment for stats, thanks!
lets deafeat the mighty algorithm
youtube algorithm prayer
pluto is a planet
this is for Bro !! :)
#defeat the algorithm
🌸
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!
That sounds like a non mechanical keyboard, I distrut
oh, no, not the police 😬
youranas:)
public enum Gigachad {
MUSCULAR,
SHREDDED,
KNOWS_CODE,
CHISSELED,
IS_NAMED_BRO_CODE,
OVER_9000
}
pls don't call the po po😂
"If you don't I'm calling the police" like this line :D
come on Elon Musk, whats taking so long ? 🤣🤣
the Third
URANUS
Pluto