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?
import java.util.Scanner;
public class Example {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String s = scan.next();
System.out.print("String: " + s);
}
}
Aucun commentaire:
Enregistrer un commentaire