Java enum 🪐

Поділитися
Вставка
  • Опубліковано 27 січ 2025

КОМЕНТАРІ • 142

  • @BroCodez
    @BroCodez  4 роки тому +69

    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;
    }
    }

    }

    • @Creativeprogrammer237
      @Creativeprogrammer237 3 роки тому

      Very helpful video bro

    • @kageemo
      @kageemo 3 роки тому +1

      hi if i wish to random select a enum how do i go about doing that?

    • @ernestchikuwa9935
      @ernestchikuwa9935 2 роки тому

      make int number final

    • @joyceasante8292
      @joyceasante8292 Рік тому +1

      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;
      }
      }
      }

  • @nikolozlatsabidze
    @nikolozlatsabidze 2 роки тому +112

    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

    • @BroCodez
      @BroCodez  2 роки тому +39

      that's awesome! Tell everyone I said hi!

    • @Jo70964s
      @Jo70964s Рік тому +6

      lmfaooo

    • @ninopino12
      @ninopino12 Рік тому +4

      🤣🤣@@BroCodez

    • @thenermer
      @thenermer 9 місяців тому +2

      Hah I watch them even when it IS raining

    • @alexg6720
      @alexg6720 14 днів тому

      Write "if it is not raining" as a if statement.
      I know you wont, so here.
      public class Main {
      public static void main(String[]args){
      boolean rain;
      if (rain==true){
      System.out.println("Thank you , my whole village is grateful to you . We watch all your videos together at village center every day

  • @spenzr6920
    @spenzr6920 2 роки тому +27

    That "YOURANUS" caught me off-guard lmao, good tutorial btw 👍

  • @MrRexxarHell
    @MrRexxarHell 2 роки тому +13

    I really like your sense of humor when you teach things, it makes it more fun. Keep it this way!

  • @insalia8216
    @insalia8216 3 роки тому +25

    Thank you, bro! This was really helpful, especially with a mix of humor in your explanation. I enjoyed watching it while also learning :)

  • @AlirezaYadegarAzary
    @AlirezaYadegarAzary 10 місяців тому +1

    so much struggling with the concept and finally found your video. Thanks man

  • @koyuki6113
    @koyuki6113 4 місяці тому +2

    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.

  • @Vangelis.
    @Vangelis. 4 роки тому +15

    Thank you for your Java tutorials bro. They are really helpful and easy to understand!

  • @26.hoangvanminh12
    @26.hoangvanminh12 2 місяці тому

    Your channel is so great, I have never seen a lecture in coding but concise and easy to understand like your videos

  • @alicialightner7309
    @alicialightner7309 3 місяці тому

    thank you so much your videos have been helping me through my college computer science courses!!!!

  • @iyar220
    @iyar220 Рік тому

    You are one of the most helpful people on youtube!

  • @abdulrahmanfattal5140
    @abdulrahmanfattal5140 2 роки тому +2

    Man, you are the best. I always watch your videos to learn new languages and you make it really easy. Keep it going 👍🏻👍🏻.

  • @mafakka2
    @mafakka2 3 роки тому +9

    well if you consider Australia as a planet then yes, Pluto is a planet too, since its size.equal(Australia)

  • @rivazmardani
    @rivazmardani 3 роки тому +4

    he's officially become the new lord & saviour on java cult😁
    thx bruh it's rly helpfull

  • @ВалерійЛуцьо-и6о
    @ВалерійЛуцьо-и6о 2 роки тому

    Best Java tutorials are on this channel! Thanks, Bro!

  • @SatrixPlaysGames
    @SatrixPlaysGames 2 роки тому

    My first time here, loved the tutorial! I like your humor.

  • @faizalimuhammadzoda4731
    @faizalimuhammadzoda4731 2 роки тому

    Thanks for sharing. I like all of your videos.

  • @girl6994
    @girl6994 4 роки тому +9

    I feels I really want to be a English native speaker, it’s so important in learning coding

    • @BroCodez
      @BroCodez  4 роки тому +3

      it helps lol

    • @ottttoooo
      @ottttoooo 3 роки тому

      or you know, you can always invent coding in your language

    • @gilililili
      @gilililili 3 роки тому +2

      @@ottttoooo but they'd have to make it from a programming language in English

    • @formlessavatar5220
      @formlessavatar5220 3 роки тому +1

      Very true lol. Oh, and Sanskrit would probably help too haha

  • @MoSi-v6z
    @MoSi-v6z Рік тому

    The YOURANUS joke got me haha, your dry humor is quite funny

  • @Bdbdjdidnbwk
    @Bdbdjdidnbwk 11 місяців тому

    Thank you bro for such a clearly explaining.

  • @blabberq
    @blabberq 3 роки тому +1

    Your sense of humor just gets me xd

  • @Ragehunter
    @Ragehunter Рік тому

    4:59 THANK YOU VERY MUCH BRO NOW I SOLVE THIS

  • @angelcastineira2561
    @angelcastineira2561 4 роки тому +27

    enum GalicianWeekday{
    LUNS(1),
    MARTES(2),
    MERCORES(3),
    XOVES(4),
    VENRES(5),
    SABADO(6),
    DOMINGO(7);
    int number;
    GalicianWeekday(int number){
    this.number = number;
    }
    }

  • @aaronlambert8151
    @aaronlambert8151 Рік тому

    Thanks for yet another great video. ❤

  • @alyssapuype732
    @alyssapuype732 8 місяців тому

    Very good video!

  • @unlockme1424
    @unlockme1424 3 роки тому

    Gracias bro

  • @mirlsgrabbaszad594
    @mirlsgrabbaszad594 8 місяців тому

    Perfect as always

  • @FarukqO
    @FarukqO Рік тому

    Appreciate the hard work Bro Code

  • @kartikbishnoi9893
    @kartikbishnoi9893 2 роки тому

    Great

  • @_I_LOVE_CHOCOLATE_
    @_I_LOVE_CHOCOLATE_ 2 роки тому

    This video is awesome!!

  • @chizuruokeonyedim506
    @chizuruokeonyedim506 2 роки тому

    great content

  • @zed5551
    @zed5551 2 роки тому

    Great intro tutorial to enum.

  • @King.GeorgeM
    @King.GeorgeM 2 роки тому

    Very good

  • @angelrpozas6736
    @angelrpozas6736 Рік тому

    Great video!

  • @eugenezuev7349
    @eugenezuev7349 7 місяців тому

    Thank you for you

  • @kemann3815
    @kemann3815 3 роки тому

    Awesome

  • @Dm__0612
    @Dm__0612 3 дні тому

    Thank you Bro ❤❤❤

  • @ahsanshahzad610
    @ahsanshahzad610 2 роки тому

    great

  • @percivalgebashe4376
    @percivalgebashe4376 Рік тому

    Nice

  • @nawfalnjm5699
    @nawfalnjm5699 3 роки тому

    thank you , your videos are awesome !

  • @theia1357
    @theia1357 Рік тому

    Bro you are hella funny without even trying

  • @hugoresende5620
    @hugoresende5620 3 роки тому +5

    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;
    }
    }
    }

  • @obzdg9953
    @obzdg9953 2 роки тому

    showing next level is a good idea, thank you bro. Will you upload more videos? what should we do after your videos?

  • @jackwolf5663
    @jackwolf5663 Рік тому

    THANK YOU Bro))))

  • @parsava_localize
    @parsava_localize Рік тому

    Perfect!

  • @mackensonreginaldmichel399
    @mackensonreginaldmichel399 2 роки тому

    Thanks a lot. What if we wanted to put it in a constructor ? How would that be done? Thanks again.

  • @jonathansutanto2033
    @jonathansutanto2033 3 роки тому

    omg very useful to me,thanks :D

  • @ChosenInvisiball
    @ChosenInvisiball 10 місяців тому +1

    "Come on elon what's taking so long" Oh boy did this age like milk

  • @Fabian008
    @Fabian008 2 роки тому

    Thank you bro!

  • @MO-dd3cs
    @MO-dd3cs 4 роки тому +1

    Thank you ♡

  • @AdekunleJimoh-e1v
    @AdekunleJimoh-e1v Рік тому

    Thank you

  • @renemendy4880
    @renemendy4880 2 роки тому

    Thanks

  • @ahmetkarakartal9563
    @ahmetkarakartal9563 3 роки тому

    thank you so much

  • @gaurav9362
    @gaurav9362 3 роки тому +3

    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;

    }
    }
    }

  • @chungfup1493
    @chungfup1493 2 роки тому

    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

  • @nouraldinurfan5024
    @nouraldinurfan5024 5 місяців тому

    thank you but how often do we need to use enum.

  • @Alibeee87
    @Alibeee87 3 роки тому

    Thanks bro

  • @Soul93724
    @Soul93724 8 місяців тому

    🎉🎉🎉🎉

  • @alexg6720
    @alexg6720 14 днів тому +1

    Why did i get a notificasion from the FBI

  • @leangsengly2876
    @leangsengly2876 2 роки тому

    thank you

  • @JeongwooMog
    @JeongwooMog Рік тому

    are enums pretty much objects? are they arrays? or sets?

  • @sanskarsongara2592
    @sanskarsongara2592 4 роки тому +1

    2:56 I pray musk hear you soon :-)

  • @andrewfog2466
    @andrewfog2466 2 роки тому

    cool

  • @DetCoAnimeFan
    @DetCoAnimeFan 3 роки тому +1

    enum Subjects
    {
    ENGLISH_LIT,
    ENGLISH_LANG,
    HINDI,
    COMPUTER_SCIENCE,
    PHYSICS,
    CHEMISTRY,
    MATHS;
    }

  • @danielmilewski7659
    @danielmilewski7659 2 роки тому

    thanks bro!

  • @phoboslabsreviews
    @phoboslabsreviews 2 роки тому +1

    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;
    }
    }

  • @Mal-nf2sp
    @Mal-nf2sp 3 роки тому

    I love how the music of this tutorial is like a minecraft video🤣

  • @NichtAnwesend
    @NichtAnwesend 11 місяців тому

    du hast mich nicht enttäuscht :)

  • @Healthyroutines.
    @Healthyroutines. 4 роки тому

    thank bro

  • @changyou4454
    @changyou4454 3 роки тому

    Dropping a comment.

  • @saibadam
    @saibadam 3 роки тому

    Dropping a comment

  • @patrik6775
    @patrik6775 Рік тому

    enum Color {
    RED(1),
    GREEN(2),
    BLUE(3),
    int number;
    Color(int number){
    this.number = number;
    }
    }

  • @deepdaddy1208
    @deepdaddy1208 4 роки тому

    Yes bro

  • @zari_723
    @zari_723 2 роки тому

    great soundtrack xD

  • @manuelgonzalezpalafox2627
    @manuelgonzalezpalafox2627 2 роки тому

    Ly bro 4

  • @enfieldli9296
    @enfieldli9296 2 роки тому

    Tell me why you are so cool bro

  • @19hectorm
    @19hectorm 3 роки тому

    enum Ocean{
    PACIFIC(1),
    ATLANTIC(2),
    ARTIC(3),
    INDIC(4),
    ANTARTIC(5)
    int number;
    Ocean (int number){
    this.number=number;
    }
    }

  • @bestlistener1
    @bestlistener1 Рік тому

    enum Week{
    SUNDAY(0),
    MONDAY(1),
    TUESDAY(2),
    WEDNESDAY(3),
    THURSDAY(4),
    FRIDAY(5),
    SATURDAY(6) ;
    int number;
    Week(int number){
    this.number =number;
    }
    }

  • @alegamer-uw2zp
    @alegamer-uw2zp Рік тому

    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";
    }
    }
    }

  • @yuvalmorami1020
    @yuvalmorami1020 Рік тому

  • @danielmilewski7659
    @danielmilewski7659 2 роки тому

    comment for stats, thanks!

  • @developerjunior446
    @developerjunior446 3 роки тому

    Like!

  • @nehalayaaz9406
    @nehalayaaz9406 4 роки тому

    🌸

  • @tcbj2003
    @tcbj2003 2 роки тому

    thanks gigachad

  • @TheFlyingSquirrel630
    @TheFlyingSquirrel630 6 місяців тому

    I’ve been on the run for over 4 years now…

  • @joaoluis3042
    @joaoluis3042 2 роки тому

    "Youranus" ... I'm dead ^^

  • @user-vh3lm3qo4t
    @user-vh3lm3qo4t 3 роки тому

    One for the algorithm

  • @kemann3815
    @kemann3815 3 роки тому

    Ive been thinking about a constant list but i cant think of one ffs lol guess ima go to jail then ...

    • @BroCodez
      @BroCodez  3 роки тому +1

      run! The police are coming for you!

  • @surajrao8251
    @surajrao8251 7 місяців тому

    pluto is a planet

  • @hermitmobile1742
    @hermitmobile1742 3 роки тому

    youtube algorithm prayer

  • @thelastdiver3228
    @thelastdiver3228 8 місяців тому

    this is for Bro !! :)

  • @kapebreak
    @kapebreak Рік тому

    lets deafeat the mighty algorithm

  • @ginasomara267
    @ginasomara267 3 роки тому

    #defeat the algorithm

  • @alvaroabaddedonesteve5988
    @alvaroabaddedonesteve5988 2 місяці тому

    That sounds like a non mechanical keyboard, I distrut

  • @bulatovicvuko6552
    @bulatovicvuko6552 Рік тому

    come on Elon Musk, whats taking so long ? 🤣🤣

  • @Snowmanver2
    @Snowmanver2 3 роки тому

    oh, no, not the police 😬

  • @kasparovfazil0309
    @kasparovfazil0309 14 днів тому

    İt gittin gideli, it 'll be good

  • @barknbryce6993
    @barknbryce6993 3 роки тому

    Pluto

  • @Healthyroutines.
    @Healthyroutines. 4 роки тому

    the Third

  • @AG-qp7gn
    @AG-qp7gn 3 роки тому

    enum