+ 2

Why this not work?

import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); int a=myvar.nextint(); System.out.println(a); } }

3rd Jul 2018, 6:00 AM
Saeed Mosavyzadeh
Saeed Mosavyzadeh - avatar
8 ответов
+ 8
int a = myVar.nextInt(); 👍
3rd Jul 2018, 6:09 AM
D_Stark
D_Stark - avatar
+ 4
Java is case sensitive
3rd Jul 2018, 6:02 AM
Lstiti
+ 3
You have 2 errors because Java is case sensitive. Scanner myVar = new Scanner(System.in); int a=myvar.nextint(); myVar is not the same as myvar. They are 2 separate variables. Also Java uses CamelCase for methods, so nextint() should instead be nextInt() - uppercase i.
3rd Jul 2018, 6:10 AM
Shardis Wolfe
+ 3
Saeed nextInt(capital i) works
3rd Jul 2018, 6:37 AM
Sad
Sad - avatar
+ 1
Leszek but when we write int its work but nextint doesnt
3rd Jul 2018, 6:18 AM
Saeed Mosavyzadeh
Saeed Mosavyzadeh - avatar
0
insertInt();
3rd Jul 2018, 1:16 PM
Driss Aharik
Driss Aharik - avatar
0
Driss Aharik java.util.Scanner class does not have an insertInt() method. Most of its methods are of the form hasNext<type>() or next<type>(), such as the nextInt() used here.
3rd Jul 2018, 1:25 PM
Shardis Wolfe
0
sorry for the mistake nextInt();
3rd Jul 2018, 1:26 PM
Driss Aharik
Driss Aharik - avatar