+ 1
Java help input output
I need some help with input and output and why my code is not working. can somebody kind of explain to me why my code is throwing me an error. I want to store user input in the variable name I know I called the Scanner right at least I believe but for some reason after I added the name=input.next line(); it says no output or that the period is not known. https://code.sololearn.com/cNfshpppXxJY/?ref=app
2 Answers
+ 4
In case you didn't know, Java is case sensitive. That said, everything about your program is correct except for 'nextline()'. Just replace that with 'nextLine()' and you'll be good to go âș
0
import java.util.Scanner;
class Myclass{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String message,name;
message = "Hello, What is your name?\n\n";
name=input.nextLine();
System.out.println(message + "Hello " + name + ", Nice to meet you!");
}
}