My example input: Welcome to Java
My output with this code: Welcome
Expected output: Welcome to java
What is wrong with the following code where it accepts multiple characters with spaces? If I use nextLine(), then I will not be allowed to input a string.
I figured it out. Thanks for the help.
import java.util.Scanner;
public class Example {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        double d = scan.nextDouble();
        //edited*******************
        String s = scan.nextLine();
        s = scan.nextLine();
        //*************************
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
}
 
    