I am trying to read a String and output it to the terminal, as well as a few primitives, but it does not seem to work. The code is below:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
double d = scan.nextDouble();
String s = scan.nextLine();
scan.close();
System.out.println("String: " + s + "\n");
System.out.println("Double: " + d);
System.out.println("Int: " + i);
}
}
I have tried to find other ways to parse the string in the Scanner class, but none of them seemed to work. What I except is for the String to be properly read and outputed to the terminal, along with the few other values.
Thanks in advance.