0

Why is it giving error of not being able to compare to an int?

import java.util.Scanner; public class check{ public static void main(String[]args){ boolean a; Scanner x=new Scanner(System.in); a=x.nextBoolean(); if (a==0) System.out.println("Fail"); else System.out.println("Pass"); } }

18th Oct 2018, 2:18 PM
shantanu sontakke
shantanu sontakke - avatar
3 odpowiedzi
+ 1
compare it to boolean if(a==false) or if(a==true) you can make it simpler by if(a) or if(!a)
18th Oct 2018, 2:32 PM
Taste
Taste - avatar
0
you cant compare boolean with int in java compare boolean with boolean or int with int.
18th Oct 2018, 2:23 PM
Taste
Taste - avatar
0
Then what should I do
18th Oct 2018, 2:24 PM
shantanu sontakke
shantanu sontakke - avatar