Тёмный

switch vs. if-else in Java 

Neso Academy
Подписаться 2,7 млн
Просмотров 86 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 37   
@bubbly6379
@bubbly6379 4 года назад
Oh man if only yanderedev knew about this video. He'd lose his job. Thanks, I was looking for a way to not have to nest if statements :)
@cate01a
@cate01a 4 года назад
he had or he would?
@mendra7873
@mendra7873 3 года назад
stfu with that ! you're just a rager
@realdragon
@realdragon 4 года назад
But why use switch case is I can use 2 pages of if else statements in my game
@a.human.
@a.human. 3 года назад
More efficient
@inestrix7797
@inestrix7797 3 года назад
@@a.human. why?
@gatopur
@gatopur 3 года назад
for learning for example
@Olesia-s1c
@Olesia-s1c 2 года назад
So easily and at the same time concisely explained! Thank you
@manikumartharmaraj2333
@manikumartharmaraj2333 4 года назад
I continuously watching your videos from the year 2017... It's too great... I learned a lot from your videos.. I have a question to ask you... Till now you uploaded only for C Programming concepts When will you upload data structures concepts? Plz reply me if you see this Thank you neso academy
@suswithcherry9252
@suswithcherry9252 8 месяцев назад
import java.util.Scanner; class Check { public static void main(String[] args) { System.out.print("Enter an integer: "); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); switch (n % 2) { case 0 : System.out.println(n + " is an even number."); break; default : System.out.println(n + " is an odd number."); break; } } }
@arpitdwivedi354
@arpitdwivedi354 4 года назад
Love the video
@thekadend
@thekadend Год назад
Very clear and well put together. Thank you!
@saikrishnathota5972
@saikrishnathota5972 4 года назад
Resume Network theory classes
@minigamingtelugu6521
@minigamingtelugu6521 Год назад
@girishsuraskar1514
@girishsuraskar1514 3 года назад
import java.util.Scanner; public class Switchassignment { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.print("Enter your digit: "); int i1= input.nextInt(); int i2 = i1%2; switch(i2) { case (1): System.out.println("Your digit is Odd = " + i1); break; case (0): System.out.println("your digit is evem = " + i1); break; default: System.out.println("you type wrong digit"); } } } I don't have any idea about coding but because of NESO ACADEMY i fell in love with coding thank you sir💖
@panx8653
@panx8653 4 месяца назад
same my solution
@jradlr
@jradlr Год назад
done
@anjanaproperties6961
@anjanaproperties6961 10 месяцев назад
Very good explanation but as per I know switch case bit faster and directly it will jump to the case it will not execute every case as you said even if you not put break statement until and unless case satisfies every line verifies in if else
@OK-ri8eu
@OK-ri8eu 3 года назад
Habibi I can sense your accent shurka for the video :)
@AbhinavXO
@AbhinavXO 2 года назад
Thanks habibi
@aydınmert-i8k
@aydınmert-i8k Год назад
allah razı olsun
@lohchiyung769
@lohchiyung769 2 года назад
Hi want to ask that is it switch case is more effective compare to if else ?
@mystcat3
@mystcat3 4 года назад
I use the condition (ternary) operator because switch cant test values on every case. Adding a switch for every value to test floods the code. Use this instead: value1 value2 ? ( ifTrue ) : ( ifFalse ) ; It seems faster than if-else. Of course for options and lists and stuff i still use switch. But the video is useful too! I do recommend to use if-else for calling "break;" in "for" and "while" loops.
@suswithcherry9252
@suswithcherry9252 8 месяцев назад
n%2 is not a boolean expression bro
@mystcat3
@mystcat3 8 месяцев назад
@@suswithcherry9252 n%2 has the truthy-falsy property on interpreted languages, so if it's 0 then it's false, and for any other number it's true
@suswithcherry9252
@suswithcherry9252 8 месяцев назад
@@mystcat3 I tried n%2 but got an error.
@JJ-xb1pz
@JJ-xb1pz Год назад
Bless you dude
@Rrrr123-12
@Rrrr123-12 4 года назад
Thank you🤍
@atikamohamed2951
@atikamohamed2951 3 года назад
thank you:)
@NewLondonMarshall
@NewLondonMarshall 3 года назад
Brilliant video, thank you!
@tryrexman8627
@tryrexman8627 4 года назад
great vid, easy to follow and to-the-point.
@shubhamsaini5542
@shubhamsaini5542 3 года назад
totla maharaj ki jay ho
@allinonencb3182
@allinonencb3182 3 года назад
SAHI SAY BOL HE WASTE HIS TIME FOR MAKING ARE FUTURE BRIGHT GIVE HIM SOME RESPECT
@whatsapwhatsapp662
@whatsapwhatsapp662 4 года назад
thank you