0

What's wrong in my code? Why is it giving error?

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

18th Oct 2018, 1:34 PM
shantanu sontakke
shantanu sontakke - avatar
1 Respuesta
+ 1
you're using scanner in wrong way, you can consider scanner used as utilities to get an input, not store the input. so you need to create another variable to store them. and dont use same name for 2 different variable. boolean x; x = a.nextBoolean(); then you can use x for your if condition
18th Oct 2018, 1:54 PM
Taste
Taste - avatar
En tendencia hoy
.
1 Votes
What?
0 Votes
HTML
0 Votes
Web
0 Votes
Quiz duel
0 Votes
FRC Coding?
1 Votes
AI
2 Votes
help
0 Votes
APIs
1 Votes