Java enum 🪐

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

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

  • @BroCodez
    @BroCodez  4 года назад +67

    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 Год назад +108

    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  Год назад +38

      that's awesome! Tell everyone I said hi!

    • @Jo70964s
      @Jo70964s Год назад +6

      lmfaooo

    • @ninopino12
      @ninopino12 Год назад +4

      🤣🤣@@BroCodez

    • @thenermer
      @thenermer 8 месяцев назад +2

      Hah I watch them even when it IS raining

  • @spenzr6920
    @spenzr6920 2 года назад +25

    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!

  • @koyuki6113
    @koyuki6113 3 месяца назад +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.

  • @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 9 месяцев назад +1

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

  • @Vangelis.
    @Vangelis. 4 года назад +15

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

  • @mafakka2
    @mafakka2 2 года назад +9

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

  • @26.hoangvanminh12
    @26.hoangvanminh12 Месяц назад

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

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

  • @alicialightner7309
    @alicialightner7309 2 месяца назад

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

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

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

  • @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

  • @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 👍🏻👍🏻.

  • @ВалерійЛуцьо-и6о
    @ВалерійЛуцьо-и6о 2 года назад

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

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

    Your sense of humor just gets me xd

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

    Thanks for sharing. I like all of your videos.

  • @MoSi-v6z
    @MoSi-v6z Год назад

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

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

    Thank you bro for such a clearly explaining.

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

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

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

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

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

    Great

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

    Gracias bro

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

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

    Thanks for yet another great video. ❤

  • @alyssapuype732
    @alyssapuype732 7 месяцев назад

    Very good video!

  • @mirlsgrabbaszad594
    @mirlsgrabbaszad594 7 месяцев назад

    Perfect as always

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

    Great intro tutorial to enum.

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

    great

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

    Bro you are hella funny without even trying

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

    great content

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

    Nice

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

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

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

    Awesome

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

    Appreciate the hard work Bro Code

  • @King.GeorgeM
    @King.GeorgeM 2 года назад

    Very good

  • @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;

    }
    }
    }

  • @semilife
    @semilife 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;
    }
    }

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

    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

  • @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?

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

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

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

    This video is awesome!!

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

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

  • @eugenezuev7349
    @eugenezuev7349 7 месяцев назад

    Thank you for you

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

    Great video!

  • @nouraldinurfan5024
    @nouraldinurfan5024 4 месяца назад

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

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

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

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

    thank you , your videos are awesome !

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

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

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

    cool

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

    omg very useful to me,thanks :D

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

    THANK YOU Bro))))

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

    Perfect!

  • @Mal-nf2sp
    @Mal-nf2sp 3 года назад

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

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

    du hast mich nicht enttäuscht :)

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

    Thanks

  • @19hectorm
    @19hectorm 2 года назад

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

  • @AdekunleJimoh-e1v
    @AdekunleJimoh-e1v Год назад

    Thank you

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

    Dropping a comment.

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

    Thank you bro!

  • @MO-dd3cs
    @MO-dd3cs 4 года назад +1

    Thank you ♡

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

    thank you

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

    thank you so much

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

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

    Dropping a comment

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

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

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

    Thanks bro

  • @Soul93724
    @Soul93724 7 месяцев назад

    🎉🎉🎉🎉

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

    great soundtrack xD

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

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

    thanks bro!

  • @deepdaddy1208
    @deepdaddy1208 4 года назад

    Yes bro

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

    thanks gigachad

  • @Healthyroutines.
    @Healthyroutines. 4 года назад

    thank bro

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

    Tell me why you are so cool bro

  • @TheFlyingSquirrel630
    @TheFlyingSquirrel630 5 месяцев назад

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

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

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

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

    Ly bro 4

  • @user-vh3lm3qo4t
    @user-vh3lm3qo4t 3 года назад

    One for the algorithm

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

    Like!

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

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

    comment for stats, thanks!

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

    lets deafeat the mighty algorithm

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

    youtube algorithm prayer

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

    pluto is a planet

  • @thelastdiver3228
    @thelastdiver3228 7 месяцев назад

    this is for Bro !! :)

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

    #defeat the algorithm

  • @nehalayaaz9406
    @nehalayaaz9406 4 года назад

    🌸

  • @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!

  • @alvaroabaddedonesteve5988
    @alvaroabaddedonesteve5988 Месяц назад

    That sounds like a non mechanical keyboard, I distrut

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

    oh, no, not the police 😬

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

    youranas:)

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

    public enum Gigachad {
    MUSCULAR,
    SHREDDED,
    KNOWS_CODE,
    CHISSELED,
    IS_NAMED_BRO_CODE,
    OVER_9000
    }
    pls don't call the po po😂

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

    "If you don't I'm calling the police" like this line :D

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

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

  • @Healthyroutines.
    @Healthyroutines. 4 года назад

    the Third

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

    URANUS

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

    Pluto