Switch Case in Java #35

Поделиться
HTML-код
  • Опубликовано: 27 июл 2024
  • $1,000 OFF ANY Springboard Tech Bootcamps with my code ALEXLEE. See if you qualify for the JOB GUARANTEE! 👉 bit.ly/3HX970h
    This is how you can use switch case statements in your java programs! ✅Hopefully, what I've taught you will help you with these tricky switch statements.
    👑Start practicing now with 10 free java programs - alexlorenlee.com/
    🌅Source Code - github.com/alexlorenlee/JavaT...
    If you have if/else if statements comparing one variable over and over, a switch case statement may be easier for you. The layout for a java switch case statement looks like this:
    switch(num) {
    case 1:
    //do this
    break;
    case 2:
    //do this
    break;
    default:
    //do this
    }
    Switch cases can be better in many situations, but if your code works with if else statements instead, I wouldn't worry about it too much.
    This switch statement in java can be tricky at first... But SURELY you'll get it :) If you followed along, congrats! You learned-by-doing!
    I hope you enjoyed this tutorial on how to use switch case in java! I like to have a nice mix of java tutorials and actual projects for you all :)
    Do you want to learn how to write java code from scratch, in Java? Check out my Java Tutorial For Beginners: • Coding For Beginners I...
    Was this able to get your switch case statement working? -
    Full Java Tutorial For Beginners Playlist: • Full Java Course by Al...
    Free Tips: bit.ly/3U6HXcb
    Disclosure: The Springboard link provided is linked to my affiliate account & supports the channel.
    ~
    Alex Lee

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

  • @alexlorenlee
    @alexlorenlee  9 месяцев назад +3

    If you’re new to programming but want a career in tech, I HIGHLY RECOMMEND applying to one of Springboard’s online coding bootcamps (use code ALEXLEE for $1,000 off): bit.ly/3HX970h

  • @jaelynnsze3801
    @jaelynnsze3801 4 года назад +119

    I learn so much more here than in my actual class that now class is just a place to receive homework and I learn to actually solve the questions here . Thanks Alex !!

    • @littletath
      @littletath 4 года назад +4

      Same!! I feel like my teachers just tell me to write the code and don't explain why we actually use it but this video actually explained this so much so thank you Alex! I'll be watching your videos more often now.

    • @catrieltorrez2450
      @catrieltorrez2450 4 года назад +4

      hahahahahhaha SAAAMEE free days are good days cus i actually learn more on my own

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

      Just started coding bootcamp and my teacher is doing the same thing!

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

      Great!

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

      @@catrieltorrez2450 you pop

  • @lonestar2222010
    @lonestar2222010 3 года назад +18

    Alex, I am currently in a beginners programming class. I have learned more from your videos than my textbook and teacher combined. Thank you for your teachings and for distributing your knowledge, you are a true god send.

  • @FunnyDubz1
    @FunnyDubz1 4 года назад +41

    My new favorite RUclipsr! You always explain everything in such a easy way that even the hardest things become easy after watching your tutorials! You deserve MORE subscribers and likes.

  • @saveUyghurs
    @saveUyghurs 4 года назад +5

    Thanks, came for a refresh, you forget sometimes. Good teachers like you are rare

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

    Honestly love the way you explain what your doing in these tutorials. Really good!

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

    Thank you Alex. I’m trying to learn Software Development in my spare time. I’m a complete beginner. I’ve nearly given up a few times. Your videos are immensity helpful and one of the greatest resources I’ve found. THANK YOU ☺️

  • @oItzDegree
    @oItzDegree 2 года назад +6

    I don't know what I would do without you man. Keep up the good work!!!

  • @smoothoperator8414
    @smoothoperator8414 3 года назад +3

    Alex I just want to thank you for making these videos. You have the best content about Java for me.

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

    this has helped me understand the switch control statements a little more better, thank you for highlighting this.

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

    I'm in love with your videos. Thank you very much Alex for explaining everything in the most simple way

  • @hasancete43
    @hasancete43 4 года назад +1

    Although I am new in this field, as far as I see you are the best. Great job! Please, never give up...

  • @1cps2
    @1cps2 5 лет назад +18

    I am so proud that ur not giving up man. I watch every vid... Thx man u deserve more subs and violence

    • @alexlorenlee
      @alexlorenlee  5 лет назад +6

      1cps2 thank you so much! I try my best :)

    • @qwerasdfhjkio
      @qwerasdfhjkio 5 лет назад +13

      Violence??

    • @qwerasdfhjkio
      @qwerasdfhjkio 5 лет назад +6

      You mean audience or something?

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

      You meant 'audience' I suppose? Bro don't wish Alex bad, he's a cool guy XD

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

    Thank you so much Alex you are doing great works for the world community. I had trouble understanding JAVA but since I found your videos I'm back studying it again. Thanks a lot again.

  • @Daojuan
    @Daojuan 5 лет назад +49

    Thanks for the upload bro. Man, you explained it better than my teacher lol.

    • @alexlorenlee
      @alexlorenlee  5 лет назад +9

      DavyD thanks man, I hope you have a great day

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

    OMG this Saved my life, thank you Sifu Alex Lee! I hope your channel grows prosperous, you're honestly way better at teaching than my professor! I understood everything in your 9min video vs a 3 hour lecture at night.

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

    This was so helpful. I'm currently in an intro to Java case and this helped me so much!!!!!!

  • @jcinaty89
    @jcinaty89 4 года назад +8

    You explain things very well, i just subscribed I hope your channel grows!

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

    Thank you so much, your channel is helping me in every confusing moment!

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

    Thank you for making life easier by explaining Java. I have been watching your videos for one week and still going! My new year into 2021 is to learn Java with you. I have given up few times trying to learn java, but with your videos, I am self-motivated to sit and watch through your videos without being overwhelmed. So happy I came across your channel. Your truly a Savior! Thank You a million times, and Subscribed. I recommend your Java videos to anyone who is interested.
    Much love from NYC!

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

    I'm a first year doing java, thanks a million for all that you do

  • @Mohammad_Owais_Nazi
    @Mohammad_Owais_Nazi 4 года назад +5

    Thank you sir alex
    You helped me in such a small mistake

  • @rileyc5218
    @rileyc5218 3 года назад +4

    Broooo in less than 10 minutes Alex explained switch statements better than my professor who took like a whole lecture to explain it.

  • @JustAnotherPerson55
    @JustAnotherPerson55 4 года назад +1

    you deserve like a million subs.Thank you.I really appreciate this as one of my lessons

  • @Allen-fq5xn
    @Allen-fq5xn 4 года назад +1

    thanks, bro! keep it up! I've always watching your videos.

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

    Thank you for the videos! They help a lot in my bootcamp 🙌

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

    I really like that you show a problem then u offer a solution . Thanks

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

    Thank you very much Alex Lee! i was confused with a tutorial. I found your video, you have helped out alot, thanks again!

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

    This just made me understand switch looping more easier than my classes. Thanks a lot and keep the good work up so students like us can understand stuff easier :)

  • @sandysandy8579
    @sandysandy8579 4 года назад +1

    I am now learning the java from beginning only from your tutorial bro...thanks man...u doing great

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

    Thank you Alex. i really like your tutoring style very simple and clear.

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

    The best person ive found at helping understand java and making it simple. Thank you man

  • @michaelbigam3253
    @michaelbigam3253 4 года назад +1

    Your videos are really helpful, thank you :)

  • @MtxLk
    @MtxLk 4 года назад +1

    Thanks man, your tutorials are short and clear.

  • @ferdoushasnat4773
    @ferdoushasnat4773 4 года назад +1

    Thanks, man you saved my midterm.

  • @jonathanphillips5915
    @jonathanphillips5915 4 года назад +1

    I love you dude!! Please don't stop teaching! ❤🔥🔥

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

    man the keyboard sounds so satisfying. Love it :)

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

    Nice explanation. Finally understood switch statement!

  • @jasmine588
    @jasmine588 4 года назад +1

    Thanks for this video, very clearly explained.

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

    Thanks I really needed this!

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

    im watching all your videos and it's explaining literally all the lessons im going through

  • @josytutu1273
    @josytutu1273 4 года назад +1

    Really helpful for my understanding. Thanks

  • @ka2165
    @ka2165 4 года назад +1

    Great Explanation thank you for the video!

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

    great definition and nice concept sir love you and proud on you

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

    Getting me through Uni, Thanks for all the help!!

  • @raymondcameron
    @raymondcameron 4 года назад +3

    Please keep this up, I subscribed!

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

    thanks alex lee for such a sweet and wonderful explantion. Now i am so clear with java programs :)

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

    This was very helpful for me, thank you!!

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

    I actually understand how to do this. I have test next week and I think I'll get an A because of you!! Thank you so much!

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

    Another helpful video for me, thank you so much for making this video❤❤❤

  • @joshua.h
    @joshua.h 2 года назад +1

    This video was great as I never even knew about switches before I watched it. One thing I would have added was how to make multiple cases output the same thing without having to copy and paste it multiple times.
    For example, instead of having code like this:
    switch(objectSize) {
    case "hammer":
    System.out.println("Small Object");
    break;
    case "axe":
    System.out.println("Small Object");
    break;
    case "computer":
    System.out.println("Medium Object");
    break;
    case "backpack":
    System.out.println("Medium Object");
    break;
    case "desk":
    System.out.println("Large Object");
    break;
    case "shelf":
    System.out.println("Large Object");
    break;
    }
    You could simplify it like this:
    switch(objectSize) {
    case "hammer":
    case "axe":
    System.out.println("Small Object");
    break;
    case "computer":
    case "backpack":
    System.out.println("Medium Object");
    break;
    case "desk":
    case "shelf":
    System.out.println("Large Object");
    break;
    }

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

    Thanks for the video, it was helpful :)

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

    i love you bro i have a test tomorrow and its 11:15 pm and im still confused about switch case its completely clear now thanks so much

  • @drewza0216
    @drewza0216 3 года назад +3

    I was learning Java on W3Schools and the switch stuff confused me. This video cleared up everything that confused me thanks!

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

    Now I have the confidence to open my assignment on switch. Thanks Bro

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

    Thx for awesome tutorial helped a ton in my exams

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

    I realized that you can also put if-else statements in these cases and default.
    That's what I did when I can't put less than or equal and greater than or equal statement on cases. I put it inside of an if statement which is inside of a case statement. And it actually work.

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

    You’re a great human being thank you so much for your help!

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

    Love your videos keep up the good work !!

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

    thank you!! you help me a lot with this video!!!

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

    Thank you so much sir! I've learned a lot!

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

    your a genius. This helped me so much!!!

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

    Great video, thank you!

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

    thank you bro this helped me a lot

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

    Great and simple tutorial

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

    thanks dude this helped me a lot! i had a program where you make ur own math test and then you are able to take that test, but you could also do it in different languages. it was 2500 LINES OF CODE. but I cut it down with the switch.

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

    Thank you a lot for what u're doing. u are our hero! u really help us as student

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

    very good videos!! i understand better here than in my classes

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

    That was really useful , thanks

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

    I learn so much more then in my class thank you so much teaacher

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

    It was really helpful to me sir. Thanks. Greetings from Biafra Land.

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

    Thank you this help a lot.

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

    Thanks for the video it's really helpful

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

    Thanks dude, that's help a lot

  • @arif-go7qb
    @arif-go7qb 10 месяцев назад

    thx man it realy helped more ppl should know about this chanel

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

    Nice video...thnk u....i totally understood it

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

    Thank you Alex!

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

    Loved it good job

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

    wow this tutorials is easy to understand as always
    very very helpful !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @ljchannel3624
    @ljchannel3624 4 года назад +1

    Thanks for this video!

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

    Thanku bro you help us very much please make more videos I really appreciate you from my heart

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

    Thanks 🙏 for the wonderful teaching, I will be really proud to be your student

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

    Great video!!

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

    you are a very gooooood teacher. you deserve more subscribers

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

    you are amazing !!!! Thanks Alex ! :)

  • @arjunn4167
    @arjunn4167 4 года назад +1

    Hi Alex,
    Could you please explain about regular expression(Regex) concept in Java.
    Thanks.

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

    THANK YOU SO MUCH

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

    Thanks Alex ❤️

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

    You got a new subscriber,dude.

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

    Thank you for the vedio can you please explain also the condition while with boolean thanks

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

    You're a lifesaver! Thanks! 👏👍

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

    Thank you

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

    thanks alex

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

    Youve really switched my opinion on the case of switch case, in switchcase I would like to thank you;
    break;

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

    Hey Alex, nice video btw! I have a question. What keyboard brand are you using? It looks so cool.

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

    this is great!

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

    thank you sir for making youtube videos 💜 God Bless you

  • @whimsicalvibes
    @whimsicalvibes 5 лет назад +1

    The keyboard idea is fantastic...is it purchased as a service, can it bought on amazon? or did you do it yourself?

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

    Very helpful❤️

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

    Thank you!