The code I wrote takes only one line as input, not an entire sentence, and I want the whole sentence to be accepted as input:
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i; i= scan.nextInt(); double d; d=scan.nextDouble(); String s; s=scan.next(); System.out.println("String: " + s); System.out.println("Double: " + d); System.out.println("Int: " + i); } }
The test case is “Welcome to Java,” and it just displays a “Welcome” in the output. Everything else is working fine. Please help.
java
Sarthak rana
source share