دوست عزیز از متد ()nextLine استفاده کنید.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Type your name:");
String name = scanner.nextLine();
System.out.println("your name is: " + name);
scanner.close();
}
}