博主是Java的初学者,被String无法读入空格搞郁闷了好久。 广泛搜集,最终发现: Scanner sc =new Scanner(System.in); String str=sc.nextLine(); 这样就可以将空格读入啦。