Question: What is wrong with the following switch statement? // This code has errors!!! switch (temp) { case temp < 0 : System.out.println(Temp is negative.); break;
What is wrong with the following switch statement?
// This code has errors!!!
switch (temp)
{
case temp < 0 :
System.out.println("Temp is negative.");
break;
case temp = 0:
System.out.println("Temp is zero.");
break;
case temp > 0 :
System.out.println("Temp is positive.");
break;
}
Step by Step Solution
3.40 Rating (153 Votes )
There are 3 Steps involved in it
The comparison operator in the first and second case statements is incorrect It shoul... View full answer
Get step-by-step solutions from verified subject matter experts
