Java Scanner class reading strings [duplicate]
问题 This question already has answers here : Java Scanner class reading strings (5 answers) Closed 5 years ago . I got the following code: int nnames; String names[]; System.out.print("How many names are you going to save: "); Scanner in = new Scanner(System.in); nnames = in.nextInt(); names = new String[nnames]; for (int i = 0; i < names.length; i++){ System.out.print("Type a name: "); names[i] = in.next(); } System.out.println(names[0]); When I run this code, the scanner will only pick up the