Comment entrer une phrase en Java

Le code que j’ai écrit prend en entrée une chaîne unique et non une phrase entière et je souhaite qu’une phrase entière soit prise en entrée:

import java.util.Scanner; public class Solution { public static void main(Ssortingng[] args) { Scanner scan = new Scanner(System.in); int i; i= scan.nextInt(); double d; d=scan.nextDouble(); Ssortingng s; s=scan.next(); System.out.println("Ssortingng: " + s); System.out.println("Double: " + d); System.out.println("Int: " + i); } } 

Le cas de test est “Welcome to Java” et affiche simplement “Welcome” dans la sortie. Tout le rest fonctionne bien. S’il vous plaît aider.

vous pouvez utiliser scan.nextLine(); lire toute la ligne.

 import java.util.Scanner; public class Solution { public static void main(Ssortingng[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); double d = scan.nextDouble(); Ssortingng s = scan.nextLine(); s = scan.nextLine(); System.out.println("Ssortingng: " + s); System.out.println("Double: " + d); System.out.println("Int: " + i); } }