0
Why is this not working?
import java.util.Scanner; class dinu { public static void main(String[]args) { Scanner a=new Scanner(System.in); Scanner b=new Scanner(System.in); if(a>b&&a>2) { System.out.println("hi"); } else if(b>a||a==2) { System.out.println("hello"); } } }
3 Answers
+ 2
The default input type for "Scanner" is string so for comparison like your code you need to change the data type to Integer .
+ 1
You don't need two scanners for input. I think you are trying to compare numbers so you need int variables.