State the type of error and make it correct 1: switch (n>2) 2: System.out.println(100/0) | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

State the type of error and make it correct 1: switch (n>2) 2: System.out.println(100/0)

26th Mar 2021, 12:41 AM
Neekhil Yadav
Neekhil Yadav - avatar
3 ответов
0
error: incompatible types: boolean cannot be converted to int switch (n > 2) { ^ Exception in thread "main" java.lang.ArithmeticException: / by zero
26th Mar 2021, 2:03 AM
zemiak
0
👉Nikhil Yadhuvanshi👈 in switch case only (String, int) works not boolean or other
26th Mar 2021, 4:24 AM
Shahghasi Adil
Shahghasi Adil - avatar
0
second case should throw a division by zero error ^^
26th Mar 2021, 2:14 PM
visph
visph - avatar