Java enum 🪐

Поделиться
HTML-код
  • Опубликовано: 27 ноя 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 Год назад +104

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

      that's awesome! Tell everyone I said hi!

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

      lmfaooo

    • @ninopino12
      @ninopino12 10 месяцев назад +4

      🤣🤣@@BroCodez

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

      Hah I watch them even when it IS raining

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

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

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

  • @MrRexxarHell
    @MrRexxarHell 2 года назад +13

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

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

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

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

  • @26.hoangvanminh12
    @26.hoangvanminh12 18 дней назад

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

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

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

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

    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!

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

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

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

  • @angelcastineira2561
    @angelcastineira2561 4 года назад +26

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

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

    Thanks for sharing. I like all of your videos.

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

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

    }
    }
    }

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

    Your sense of humor just gets me xd

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

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

  • @hugoresende5620
    @hugoresende5620 2 года назад +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;
    }
    }
    }

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

    Great

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

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

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

    Great intro tutorial to enum.

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

    Thank you bro for such a clearly explaining.

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

    great content

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

    Very good

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

    great

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

    Bro you are hella funny without even trying

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

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

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

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

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

    Nice

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

    Appreciate the hard work Bro Code

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

    Very good video!

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

    Perfect as always

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

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

    Awesome

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

    Thanks for yet another great video. ❤

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

    Gracias bro

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

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

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

    Thank you for you

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

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

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

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

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

    Great video!

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

    Thanks

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

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

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

    Thank you

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

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

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

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

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

    Perfect!

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

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

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

    thank you so much

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

    THANK YOU Bro))))

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

    cool

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

    thank you , your videos are awesome !

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

    thank you

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

    Thank you ♡

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

    Dropping a comment.

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

    Thank you bro!

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

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

    Thanks bro

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

    omg very useful to me,thanks :D

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

    Dropping a comment

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

    du hast mich nicht enttäuscht :)

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

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

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

    thank bro

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

    🎉🎉🎉🎉

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

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

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

    thanks bro!

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

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

    Yes bro

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

    Tell me why you are so cool bro

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

    great soundtrack xD

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

    comment for stats, thanks!

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

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

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

    pluto is a planet

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

    One for the algorithm

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

  • @alvaroabaddedonesteve5988
    @alvaroabaddedonesteve5988 День назад

    That sounds like a non mechanical keyboard, I distrut

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

    thanks gigachad

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

    Ly bro 4

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

    #defeat the algorithm

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

    this is for Bro !! :)

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

    🌸

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

    lets deafeat the mighty algorithm

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

    youtube algorithm prayer

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

    Like!

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

    Pluto

  • @AG-qp7gn
    @AG-qp7gn 3 года назад

    enum

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

    youranas:)

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

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

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

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

    oh, no, not the police 😬

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

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

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

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

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

    an enum