Why is my compiler telling me:
Incompatible Types:
Required: Boolean
Found: Int
under case 0 & case 1
For instance:
public void test(boolean isOn){
switch (isOn){
case 0:
if (isOn){
System.out.println("its on");
}
break;
case 1:
if (!isOn){
System.out.println("its off");
}
break;
default:
System.out.println("I don't know!");
}
}
Driver Class:
Club me = new Club();
me.test(true);
switch
andif
are redundant. – Unbodiedtrue
,false
,FILE_NOT_FOUND
! In Java, aboolean
can only have two values - true, and false. Your default case will never be reached (and most people would likely use anif
statement). Now,Boolean
(note the capital'B'
) can benull
(at which point "I don't know" makes sense), but you're not using that here... – Lise