Scanner Error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

Scanner Error

Hello i need help with scanner comand

8th Jun 2019, 1:47 AM
4 Answers
8th Jun 2019, 2:34 AM
Ghost rider
import java.util.Scanner instead of import You have initialized variable "name" with both int and Scanner data type
8th Jun 2019, 2:37 AM
Ghost rider
Hey, I edited your code, take a look at it here - it's got comments with explanation but in short: - You used instead of java.util - Scanner name is ambiguous, you might use it to get user age, date of birth, any string so just calling it "scanner" or sc or userInput is better than calling it 'name' - you used int for name, I assume it's better to use String for text
8th Jun 2019, 2:38 AM
HNNX 🐿 - avatar
//Scanner name = new // Scanner (; // name = in.nextLine () ; Scanner in = new Scanner(; String name = in.nextLine ();
8th Jun 2019, 7:55 AM