What's new in Java Switch | Switch Statement and Expression

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

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

  • @ashutoshpalit2204
    @ashutoshpalit2204 2 года назад +44

    Its good that they have finally updated the switch statement syntax. Not that I had any issue with the previous syntax with break statement but now the arrow syntax definitely makes the code more readable and easier to write. And I just love the fact that they have added the return feature in switch, it makes a lot of things easier😁

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

      as an old school learner, the old switch syntax was cooler, no offence to the new learners.

  • @bhanuprakashreddy4834
    @bhanuprakashreddy4834 Год назад +8

    00:03 Updated version of switch statement in Java
    01:32 Using switch statements in Java
    02:55 Application to set alarms based on the day
    04:19 Waking up schedule
    05:42 Updated version of system.twintellin has new features.
    07:04 Assigning a value to a variable instead of printing it directly
    08:27 Using switch as an expression
    09:51 Java 12 introduces the use of 'yield' instead of 'break' in switch statements

  • @saishiny6684
    @saishiny6684 Год назад +11

    The way you explain is excellent sir. Iam very grateful to you sir.I hope one day I can explain like this to others.

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

    That's the benefit of following Navin sir's videos!
    Thank you sir for sharing :)

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

    Love and respect from 🇨🇩🇨🇩🇨🇩 your channel has helped me a lot NAVIN.

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

    I liked it and felt more relevant than old syntax

  • @Heyaadi01
    @Heyaadi01 4 месяца назад +3

    I really like your explanation... I really wanted to you as a Java Teacher in my College 😄

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

    I like the switch updates. Thanks man 👍

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

    I like this syntax... Thanks for keep updating us.. i hope you will give such update in future also.

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

    Love the new switch syntax! Didn't have an issue with the old way as it is more expressive but this new way has certainly grown on me.

  • @kamakshijayaraman3747
    @kamakshijayaraman3747 11 месяцев назад +5

    i liked old switch statement

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

    When we need to write more than one line in cases,how can we use arrows sir.

    • @CICADA-ci8pr
      @CICADA-ci8pr 3 месяца назад

      Good question bro

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

      switch (day) {
      case 1 -> {
      System.out.println("Monday");
      System.out.println("This is an other instruction");
      }
      You need to pay attention here, you will not have a return statement ,the switch case statement should not return a value (like the old switch case version)

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

    So Amazing teaching style sir thank you🎉🎉🎉🎉🎉

  • @yashjangid4222
    @yashjangid4222 2 месяца назад +1

    sir we need to take the valur in input then what we have to do like for EX- enter the day = " " //then it gives the time

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

    Looks readable & amazing!!

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

    java --version
    java 12.0.2 2019-07-16, I see java 12 in my system, but this syntax not working, getting an error.

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

    Great features. Very informative video. 🔥

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

    I like the arrow operator, without the "break" statement. I see lots of similarities between C and Java, I am C embedded designer. I am planning to use Java for embedded (small computer forms - Microcontroller based) web servers. In your openion, what is a good Java flavor, library, extension and whatever that best fits for embedded designers? Is there a Java package that is dedicated mainly for embedded (hardware and software) designers? What is a good website that explores those possibilities? I am familiar with Eclipse, Andorid Studio, and many dedicated IDEs that belong to silicon manufacturers and their likes among IDEs - your help is greatly appreciated.

  • @naveenkatakam8082
    @naveenkatakam8082 23 дня назад

    This is cool and easy to understand

  • @ajayghode3602
    @ajayghode3602 11 дней назад

    Wonderful video
    Thank you

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

    Thank you I like the new update it helps me reduce the amount of text typed when coding.

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

    For Saturday and Sunday you set an alarm clock earlier than for weekday. Java developer as is.

  • @deebaksharma7556
    @deebaksharma7556 10 месяцев назад +1

    Why it is not working in vs code?

  • @22_ankanamajee97
    @22_ankanamajee97 Год назад

    very much liked this new switch case functions

  • @Ahmadzai-15
    @Ahmadzai-15 Год назад

    Amazing the new method 👍

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

    What if we have to execute Multiple statements after -> or yeild ?

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

      for that simple use previous concept of switch;

  • @thatvikreddy9458
    @thatvikreddy9458 6 дней назад

    Thanks for the amazing course. I am unable to open Git, could you please help.

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

    Really good future and thank you for explaining us

  • @lalit-singh-bisht
    @lalit-singh-bisht Год назад

    do we have to write it in a block with there are multiple statements associated with a case

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

    Correction: Strings are supported from Java 7

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

    is this update a good way? In case I need to continue the block. what can I do in the update switch statement? I think this update is easy to write a code but how do we continue the block?

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

    after arrow operator , can we use compoud statement?

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

    Thank you for your teaching

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

    Sir please make videos on frontend development using python programming .please sir

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

    IT IS very good feature I like this new feature

  • @7amalex763
    @7amalex763 Год назад

    It's definitely welcome feature to not have to declare a break statement on all my switch cases.

  • @yashjangid4222
    @yashjangid4222 2 месяца назад +1

    superb

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

    Is there any relationship with Lemda -> or switch ->

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

    finally, now they are adopting kotlin syntax.

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

    I feel we don't need to put break at the end of case. Next case starting means end of the previous. Hope they remove that break without changing the syntax

  • @underflo43tky
    @underflo43tky 8 дней назад

    what ide are you using here?

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

    Thank you so much sir ❣️

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

    Where you got updated these things sir

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

    What if for each case we want to return different data types then how we can assign switch case to reference variable (result)

  • @saurabhkumar-xm8wb
    @saurabhkumar-xm8wb Год назад

    Can we write multiple line statements in cases as we do in lambda expression using open close braces?

    • @hey-cg3fv
      @hey-cg3fv Год назад

      yes but use yield keyword

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

    why am I getting an error when using multiple cases in single case
    public class Main
    {
    public static void main(String[] args) {
    String d="f";

    switch(d)
    {
    case "f", "m":
    System.out.println("work");
    break;
    case "sat":
    System.out.println("gym");


    }
    }
    }
    ERROR:
    Main.java:19: error: : expected
    case "f", "m":
    ^
    1 error

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

      i am not facing any issue bro
      public class hello{
      public static void main(String[] args){

      String d="f";


      switch(d)
      {

      case "f", "m":
      System.out.println("work");
      break;
      case "sat":
      System.out.println("gym");

      }
      }
      }

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

    Yes, I enjoyed your video!

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

    Where can I see new updates like this?

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

    Commenting for the algo. Quality content.

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

    What if we want to have more than one statement in updated switch block..

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

    New syntax is much better, I liked the -> arrow ones to writing yield

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

    I don't know but have gut feeling soon java will be standing next to python and R for ML or may be for block chain

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

    the format case "monday" -> output is not working ..showing like invalid syntax

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

    its good for understanding sir

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

    Other guys- hello students, what's up guys
    He - welcome back 👽

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

    break seems like good for kick start/

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

    So basically they allow to put lambda expressions in switch case

  • @Myworld-gb6rz
    @Myworld-gb6rz Год назад

    thank u very much actually it's makes a sense

  • @raviteja-u9u
    @raviteja-u9u Год назад

    i think older version is good according to coding lines and syntax

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

    It is actually great...

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

    Sad that pattern Matching, gaurded Patterns and null-safe were not covered

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

    I loved the switch new syntax.

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

    Thanks

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

    Sir we cant use switch statement in while loop because the break statement breaks entire looop😔😔

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

    It’s similar to cpp(Most of the syntax)

  • @108vicky
    @108vicky 2 года назад

    Nice tutorial

  • @vishwasrchonu7134
    @vishwasrchonu7134 8 месяцев назад +7

    Java is copying things from python and javascript, finally!! 😂😂😂

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

      Yeah it seems

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

      ​@@deepadevi8911jejejeje. As the same python copied several features from Java and other languages.. Great! There are many changes to continue improvement our daily sofatware development..

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

    22 seconds of darkness at the end...

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

    Thank you

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

    Thank you sir

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

    Hi sir, I'm stuck as software test engineer. I need to switch to development please suggest good path. I'm flexible in coding language

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

    Lessons are Good, may you please not blur the board!

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

    Awesome

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

    its good

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

    I just learned you could use multiple conditionals for the same case... I just copied the code 2 times.

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

    Thanks sir

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

    I like it.

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

    I never understood the concept of the old switch needing the break. I guess it serves a purpose for some people, but it makes no sense to me.

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

    Great

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

    good

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

    THAT'S GREAT

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

    This video series is unique but language problem 😢 Hindi or English mix rahta

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

    java is the new kotlin

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

    Shit java is too much every time I think I reach the end of a lesson , some new thing always comes up. I haven't gotten any where as yet to build a project. But any way I'll try.

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

    Coming from golang its normal but here looks like oracle or Java communities trying hard to catch up with modern language like go.

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

    I'd stick to the old syntax

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

    nice

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

    I think it's a good thing but old switch is better than this 😁

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

    Nice feature😅

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

    🙌

  • @KarthiKeyan-ov3es
    @KarthiKeyan-ov3es 2 года назад

    Similar to kotlin

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

    I don't even know Java 8 and Java is at v17🤦 after v100 Java will be rebranded to new jabaa language 😁😁

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

    ♥️

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

    Lol, thus python is good 🤣🤣

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

    Better create new language for this. It makes java more complicated. This is good for intelligent people. How about the average? Maybe they have no right to become a developer.

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

    Thank you

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

    Great