Switch Case in Java #35
216.4K views on YouTube
$1,500 OFF ANY Springboard Tech Bootcamps with my code ALEXLEE1500. See if you qualify for the JOB GUARANTEE! 👉 https://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 – http://alexlorenlee.com/
🌅Source Code – https://github.com/alexlorenlee/JavaTutorialCode/blob/master/Conditionals/SwitchCase.java
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: https://youtu.be/woJb2hAfkO0
Was this able to get your switch case statement working? –
Full Java Tutorial For Beginners Playlist: https://youtube.com/playlist?list=PL59LTecnGM1NRUyune3SxzZlYpZezK-oQ&si=6OSbyiJxFsTjqL_9
Free Tips: https://bit.ly/3U6HXcb
Disclosure: The Springboard link provided is linked to my affiliate account & supports the channel.
~
Alex Lee