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!"); }
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.
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
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; }
It is not Lambda expression it is called (Lambda-like syntax) .. Lambda is the replication for the anonymous inner class ..but may be we can name as enhanced switch
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.
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
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.
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 (
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
@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?
One more thing you can do instead of having to change the day string value is to ask the user to input the day using scanner. However, my question here is how to implement equalsIgnoreCase here? import java.util.Scanner; 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 Scanner scanner = new Scanner(System.in); String day = scanner.nextLine(); 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!"); } } }
in 3:37 seconds of your video why it is sunday! is not displayed rest all days except monday and sunday are displayed while the switch is on monday only but else must have been displayed but sunday is also in the output....kindly answer my doubt.... rest explaination were nice but i got a doubt in the above things that i have mentioned.. kindly clear my doubt bro......
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
Teachers seeing this and making it 2 hours long:
real, so much unnecessary words to be included during discussions
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
@@deiti
public class Human {
public static void main(String args[]) {
System.out.println("Awesome Explanation!");
}
}
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
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
It is not Lambda expression it is called (Lambda-like syntax) .. Lambda is the replication for the anonymous inner class ..but may be we can name as enhanced switch
Learning the beginnings of Java in school but the tricks in these tutorials are awesome like: sysout + strg/ctrl + space
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^)(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(๑˙❥˙๑)(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(๑˙❥˙๑)(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。(◍•ᴗ•◍)✧*。
Tomorrow i've got a Java exam in school, and this helped a lot. Thanks
your tutorials are always amazing thanks bro
An exciting and brief course by bro absolutely amazing may your channel grow big Af
bro, thank you for everything, you helped me pass my ict subject and make coding fun!
Really love your videos.I need to support you!!!!
Your the best Java Teacher on youtube.
im going to like all your videos. you are saving me. thx bro !!!
I always come back to this channel to learn anything
Love ur videos bro :>
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
You teached me alot sir, Thank you!
best switch case explanation
I used to think if statements were useless because switch cases exist, but I now know that switch cases can't check for all types of values.
I don't know what i have to comment, just wanna comment to support this channel tho
Thank you for your efficiency!
Thank you so much. Well explained
Was debugging one hour, because forgot to add breaks
BRO code !!! You are the chosen one, to be the None Indian UA-cam Teacher :))
the good thing in the switch tag is that we can put another condition inside of it.
This is really lit bruh🔥🔥
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.
Best channel ever!
thank you brother you saved my day🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰😍😍😍😍😌😌😌😌
Thanks man
very much appreciate it
Thank you, Bro Sensei👍
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 (
you are a hero bro
Well explained!
Thanks for the video
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
Great video!
Thanku Bro🙏🙏🙏🙏
good video bro!
Thank you🙌
you are amazing!
Switching case the next lesson, default is learning
Thank you again 💙💙
well explained
Can we apply switch case to integer also ?
Easy! Thank you
I like your teaching style. hhhh
thank you!
A legend
i wonder if python has a similar way for handling multiple conditions
So can you add 3 together like
Sunday , Monday and Tuesday
Instead of putting too many break ;
Thanks!
doing my part for the algorithm
Yeah I become a hero !!
you are the best.
I love you chanel !!!
Thank you bro
Thanks, bro
Super!
@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!
Ily so much
Thank you bro code!
W EXPLANATION 💥
thank u so much
❤❤❤❤❤ great 🎉🎉🎉🎉
Thanks
One more thing you can do instead of having to change the day string value is to ask the user to input the day using scanner. However, my question here is how to implement equalsIgnoreCase here?
import java.util.Scanner;
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
Scanner scanner = new Scanner(System.in);
String day = scanner.nextLine();
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!");
}
}
}
Thanks bro
System.out.println("you gave one of the best explanation , thank you bro ");
thanks
thx 4 vid bro
Thanks, bro. Algorithm comment
I'm a hero
Thanks Bro code ❤
If I become president, I will make pizza the 8th day of the week.
ty bro
THank!
Nice.
legend
good to know
good video
comment for stats. thanks!
just switchted to the switch video
nOt FuNnY lOl
thanks brah
i though you need to give number for each case
Thanx bro
For the default statement you should have said "That is not a day, but it should be :))."
How do I do it if I want to pick a random variable in the switch statement?
cool!
God Bless you Bro +7
doing well!
What if i type "monday" instead of "Monday".
How can I ignore the case?
Btw thank u bro I love ur videos. Keep it up!
nice
thx
Like it
could you make it so that it randomly generates a day from a list so that it says a random statement instead of you manually changing it?
of course you can!
@levimonarca did you create an array list and add all of the values into that? Sorry I’m just trying to understand
Hiw?
How?
in 3:37 seconds of your video why it is sunday! is not displayed
rest all days except monday and sunday are displayed while the switch is on monday only but else must have been
displayed but sunday is also in the output....kindly answer my doubt....
rest explaination were nice but i got a doubt in the above things that i have mentioned..
kindly clear my doubt bro......
merci