Java switch ⬇【4 minutes】

Поделиться
HTML-код
  • Опубликовано: 18 окт 2020
  • Java switch statement
    #Java #switch #statement
    public class Main {
    public static void main(String[] args) {
    // switch = statement that allows a variable to be tested for equality against a list of values
    String day = "Friday";
    switch(day) {
    case "Sunday": System.out.println("It is Sunday!");
    break;
    case "Monday": System.out.println("It is Monday!");
    break;
    case "Tuesday": System.out.println("It is Tuesday!");
    break;
    case "Wednesday": System.out.println("It is Wednesday!");
    break;
    case "Thursday": System.out.println("It is Thursday!");
    break;
    case "Friday": System.out.println("It is Friday!");
    break;
    case "Saturday": System.out.println("It is Saturday!");
    break;
    default: System.out.println("That is not a day!");
    }
    }
    }
  • НаукаНаука

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

  • @BroCodez
    @BroCodez  3 года назад +96

    public class Main {
    public static void main(String[] args) {

    // switch = statement that allows a variable to be tested for equality against a list of values

    String day = "Friday";

    switch(day) {
    case "Sunday": System.out.println("It is Sunday!");
    break;
    case "Monday": System.out.println("It is Monday!");
    break;
    case "Tuesday": System.out.println("It is Tuesday!");
    break;
    case "Wednesday": System.out.println("It is Wednesday!");
    break;
    case "Thursday": System.out.println("It is Thursday!");
    break;
    case "Friday": System.out.println("It is Friday!");
    break;
    case "Saturday": System.out.println("It is Saturday!");
    break;
    default: System.out.println("That is not a day!");
    }

    }
    }

    • @_Anna_Nass_
      @_Anna_Nass_ 2 года назад +4

      Thank you for always taking the time to put the code in the comments.

    • @trickysachin
      @trickysachin 2 года назад +2

      @@_Anna_Nass_ he can easily copy and paste lol

    • @trickysachin
      @trickysachin 2 года назад +2

      @@_Anna_Nass_ because he is smart and helpful

    • @bartekjaniec3056
      @bartekjaniec3056 Год назад +2

      You can write "->" instead of ":" and you don't need now writing break at the end
      switch(day) {
      case "Sunday" -> System.out.println("It is Sunday!");
      case "Monday" -> System.out.println("It is Monday!");
      or
      switch(day) {
      case "Sunday" -> {
      System.out.println("It is Sunday!")
      System.out.println("It's a free day!")
      };
      case "Monday" -> {
      System.out.println("It is Monday!")
      System.out.println("It's not a free day!")
      };
      }
      if you need to run more than 1 command.

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

      Sout enter and only bro code

  • @Chndnsharma28
    @Chndnsharma28 3 года назад +110

    System.out.println("Awesome explanation!") ;

    • @oxi1492
      @oxi1492 9 месяцев назад +10

      No main method found in program

    • @Sqrt.Infinity
      @Sqrt.Infinity 7 месяцев назад +5

      public class Human
      {
      public static void main(String args[])
      {
      System.out.println("Awesome Explanation!" );
      }
      }

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

      @@Sqrt.Infinity incorrect indentation

  • @epic1343
    @epic1343 3 года назад +5

    your tutorials are always amazing thanks bro

  • @pavelkvasnicka6856
    @pavelkvasnicka6856 Год назад +10

    This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro

  • @Actionkidfam
    @Actionkidfam Год назад +5

    An exciting and brief course by bro absolutely amazing may your channel grow big Af

  • @KarolKasperek
    @KarolKasperek Год назад +12

    quick reminder.
    Now you can use lambda expression:
    switch(number) {
    1 -> do something;
    2 -> do something;
    3 -> do something
    }
    instead of
    switch(number) {
    case 1: do something;
    break;
    case 2: do something;
    break;
    case 3: do something
    break;
    }

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

      what will be the default and break for this expression

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

    Really love your videos.I need to support you!!!!

  • @mpathfinder
    @mpathfinder 3 года назад +8

    Learning the beginnings of Java in school but the tricks in these tutorials are awesome like: sysout + strg/ctrl + space

  • @StandProudYouAreStrong
    @StandProudYouAreStrong Год назад +1

    Love ur videos bro :>

  • @uuijs1
    @uuijs1 5 месяцев назад +1

    bro, thank you for everything, you helped me pass my ict subject and make coding fun!

  • @coltonbailey8873
    @coltonbailey8873 3 года назад +29

    You teaches the peaches, for real. Thank you so much for taking the time to create these lessons. You've designed them in such a order, that while I'm learning I can take a new concept that you're teaching me, and apply it with one of your previous lessons easily. Right now I'm creating switch statements while interfacing a GUI. I wish you would have squeezed a video about using getText() though, because Scanner can't be used with JOptionPane apparently x). Thank you for teaching me stuff and things, Proffeser Bro.

    • @user-tl3gb5ds8n
      @user-tl3gb5ds8n 7 месяцев назад

      (⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠๑⁠˙⁠❥⁠˙⁠๑⁠(⁠ʃ⁠ƪ⁠^⁠3⁠^⁠)(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠๑⁠˙⁠❥⁠˙⁠๑⁠)(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠๑⁠˙⁠❥⁠˙⁠๑⁠)(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。(⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。

  • @sleepypanda8249
    @sleepypanda8249 Год назад +1

    im going to like all your videos. you are saving me. thx bro !!!

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

    Thank you so much. Well explained

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

    You teached me alot sir, Thank you!

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

    Well explained!

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

    I always come back to this channel to learn anything

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

    Your the best Java Teacher on youtube.

  • @chikondiphelzmapelera5794
    @chikondiphelzmapelera5794 Год назад +1

    This is really lit bruh🔥🔥

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

    Tomorrow i've got a Java exam in school, and this helped a lot. Thanks

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

    Thank you, Bro Sensei👍

  • @anyarasan8529
    @anyarasan8529 8 месяцев назад

    you are a hero bro

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

    Great video!

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

    Thank you again 💙💙

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

    Thanks for the video

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

    good video bro!

  • @user-zq6yx7of5f
    @user-zq6yx7of5f Год назад

    thank you!

  • @tanjirodluffy4403
    @tanjirodluffy4403 5 месяцев назад +1

    Thank you bro

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

    Thank you🙌

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

    you are amazing!

  • @ItsAkiresuSama
    @ItsAkiresuSama 6 месяцев назад +2

    Teachers seeing this and making it 2 hours long:

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

    I don't know what i have to comment, just wanna comment to support this channel tho

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

    well explained

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

    Easy! Thank you

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

    I love you chanel !!!

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

    Maaaan you got 170 likes and 0 dislikes this is the proof that you are really really really good i think even a monkey would understand java with your lessons you are too good at explaining it

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

    Ily so much

  • @Dev-PauloEd
    @Dev-PauloEd 2 года назад

    the good thing in the switch tag is that we can put another condition inside of it.

  • @mayamaya-px2zv
    @mayamaya-px2zv 2 года назад

    thank u so much

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

    Thanks bro

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

    Ty bro

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

    Thank you bro code!

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

    thanks brah

  • @user-qq3ix3py6l
    @user-qq3ix3py6l 10 месяцев назад

    thank you brother you saved my day🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰😍😍😍😍😌😌😌😌

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

    ty bro

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

    THank!

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

    you are the best.

  • @Abdulaziz-bj5rg
    @Abdulaziz-bj5rg Год назад

    legend

  • @grozageorge2887
    @grozageorge2887 Год назад +2

    For the default statement you should have said "That is not a day, but it should be :))."

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

    thx 4 vid bro

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

    thanks

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

    Thanks

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

    thankyou Bro

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

    Thanx bro

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

    Thanks Bro code ❤

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

    nice

  • @ramakrishnatallapragada7569
    @ramakrishnatallapragada7569 Год назад +1

    Thanku Bro🙏🙏🙏🙏

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

    I’ve been learning Java programming on my end for almost 1 month now, and all of the theoretical concepts and logic understanding is only on top of my head, I’ve got a MacBook, so I’m wondering if you have a recommendation about a program for coding to start with, I’d appreciate it since I tried but they did not work properly (

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

    good to know

  • @CartoonTv-zf2qr
    @CartoonTv-zf2qr 2 года назад

    Yeah I become a hero !!

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

    Nice.

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

    THANK YOU homie. My ass had no idea what this was in class today. Saved my ass 30 minutes to rewatching lecture videos lol. I think my professor sucks.

  • @Suraj-rv2dt
    @Suraj-rv2dt Год назад

    ❤❤❤❤❤ great 🎉🎉🎉🎉

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

    thx

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

    good video

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

    BRO code !!! You are the chosen one, to be the None Indian RUclips Teacher :))

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

    cool!

  • @Giovanni-Rhonim
    @Giovanni-Rhonim 5 месяцев назад

    God Bless you Bro +7

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

    I like your teaching style. hhhh

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

    @Bro code While making a simple rock paper scissor program I had a recommendation for a rule switch in netbeans. What is a rule switch how and when should it be used?

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

    Thanks for your explanation Bro ! May I know why it shows default whenever I type Monday with small letter m. how can i solve to show correctly without caring Monday or monday

  • @711mobiles
    @711mobiles 3 года назад

    Switching case the next lesson, default is learning

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

    doing my part for the algorithm

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

    Like it

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

    doing well!

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

    thx learnt

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

    merci

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

    How do I do it if I want to pick a random variable in the switch statement?

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

    Can we apply switch case to integer also ?

  • @oximas-oe9vf
    @oximas-oe9vf Год назад

    i wonder if python has a similar way for handling multiple conditions

  • @user-mc9uv7ij7x
    @user-mc9uv7ij7x Год назад

    ❤❤❤

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

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

    ❤‍🔥

  • @TamLe-ys7ck
    @TamLe-ys7ck 2 года назад

    Damn bro

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

    Thanks, bro. Algorithm comment

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

    ❤️👌

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

    dropped a comment

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

    4 february done

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

    pog

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

    real bro

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

    just switchted to the switch video

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

    pro gunga moment here

  • @nerrixj.l.6102
    @nerrixj.l.6102 2 года назад

    😍❤️😍❤️😍

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

    Thanks Bro!

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

    comment for stats. thanks!

  • @leechurchill1965
    @leechurchill1965 8 месяцев назад

    If I become president, I will make pizza the 8th day of the week.

  • @Jack-mr6ty
    @Jack-mr6ty 25 дней назад

    So can you add 3 together like
    Sunday , Monday and Tuesday
    Instead of putting too many break ;

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

    my comment bro thank you bro

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

    Bro#1

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

    ok bro

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

    pizza is not a day indeed