Answer the question
In order to leave comments, you need to log in
Why does java throw an error when I use Scanner?
I wrote the most lightweight program so as not to litter the question:
package ****;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.println("Enter your name: ");
String name = sc.nextLine();
System.out.println("Enter your age: ");
int age = sc.nextInt();
}
}
Answer the question
In order to leave comments, you need to log in
Aleksey Mazurkevich , please place the code in the code tag ("< / >" button in the editor). Make good indents. Otherwise, almost no one will read your code at all.
Error messages are also better wrapped in code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question