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!");
}
}
} Наука
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!");
}
}
}
Thank you for always taking the time to put the code in the comments.
@@_Anna_Nass_ he can easily copy and paste lol
@@_Anna_Nass_ because he is smart and helpful
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.
Sout enter and only bro code
System.out.println("Awesome explanation!") ;
No main method found in program
public class Human
{
public static void main(String args[])
{
System.out.println("Awesome Explanation!" );
}
}
@@Sqrt.Infinity incorrect indentation
your tutorials are always amazing thanks bro
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
An exciting and brief course by bro absolutely amazing may your channel grow big Af
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;
}
what will be the default and break for this expression
Really love your videos.I need to support you!!!!
Learning the beginnings of Java in school but the tricks in these tutorials are awesome like: sysout + strg/ctrl + space
Love ur videos bro :>
bro, thank you for everything, you helped me pass my ict subject and make coding fun!
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.
(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(๑˙❥˙๑(ʃƪ^3^)(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(๑˙❥˙๑)(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(๑˙❥˙๑)(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。
im going to like all your videos. you are saving me. thx bro !!!
Thank you so much. Well explained
You teached me alot sir, Thank you!
Well explained!
I always come back to this channel to learn anything
Your the best Java Teacher on youtube.
This is really lit bruh🔥🔥
Tomorrow i've got a Java exam in school, and this helped a lot. Thanks
Thank you, Bro Sensei👍
you are a hero bro
Great video!
Thank you again 💙💙
Thanks for the video
good video bro!
thank you!
Thank you bro
Thank you🙌
you are amazing!
Teachers seeing this and making it 2 hours long:
I don't know what i have to comment, just wanna comment to support this channel tho
well explained
Easy! Thank you
I love you chanel !!!
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
lol fr
Ily so much
the good thing in the switch tag is that we can put another condition inside of it.
thank u so much
Thanks bro
Ty bro
Thank you bro code!
thanks brah
thank you brother you saved my day🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰😍😍😍😍😌😌😌😌
ty bro
THank!
you are the best.
legend
For the default statement you should have said "That is not a day, but it should be :))."
thx 4 vid bro
thanks
Thanks
thankyou Bro
Thanx bro
Thanks Bro code ❤
nice
Thanku Bro🙏🙏🙏🙏
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 (
good to know
Yeah I become a hero !!
Nice.
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.
❤❤❤❤❤ great 🎉🎉🎉🎉
thx
good video
BRO code !!! You are the chosen one, to be the None Indian RUclips Teacher :))
cool!
God Bless you Bro +7
I like your teaching style. hhhh
@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?
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
Switching case the next lesson, default is learning
doing my part for the algorithm
Like it
doing well!
thx learnt
merci
How do I do it if I want to pick a random variable in the switch statement?
Can we apply switch case to integer also ?
i wonder if python has a similar way for handling multiple conditions
❤❤❤
❤
❤🔥
Damn bro
Thanks, bro. Algorithm comment
❤️👌
dropped a comment
4 february done
pog
real bro
just switchted to the switch video
nOt FuNnY lOl
pro gunga moment here
😍❤️😍❤️😍
Thanks Bro!
comment for stats. thanks!
If I become president, I will make pizza the 8th day of the week.
So can you add 3 together like
Sunday , Monday and Tuesday
Instead of putting too many break ;
my comment bro thank you bro
Bro#1
ok bro
pizza is not a day indeed