+ 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); } }
8 Answers
+ 8
int a = myVar.nextInt(); đ
+ 4
Java is case sensitive
+ 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.
+ 3
Saeed
nextInt(capital i) works
+ 1
Leszek
but when we write int its work but nextint doesnt
0
insertInt();
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.
0
sorry for the mistake nextInt();