+ 1

Excuse me but I don't find m'y error can you help me

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner y = new Scanner(System.in); int z = y.nextInt(); for (int x = 0; x >= y; x++){ System.out.println(x); } } }

10th Jul 2018, 7:35 PM
Raitovin
Raitovin - avatar
4 Answers
+ 2
It mentions the error. Essentially you are trying to compare an instance of Scanner (y) with an int variable (x) 'x >= y' is your error. Both values need to be of the same type, in this case 'int'.
10th Jul 2018, 7:57 PM
Duncan
Duncan - avatar
+ 2
ok thanks
10th Jul 2018, 7:59 PM
Raitovin
Raitovin - avatar
+ 2
Also, remember that 'x' starts at 0, so depending on what you're doing, you may need to change to test for '<='
10th Jul 2018, 8:02 PM
Duncan
Duncan - avatar
+ 2
ok
10th Jul 2018, 8:12 PM
Raitovin
Raitovin - avatar