public static void main(String[] args) { /* * 假如在命令行中输入:1 2 3 4 5 6 7 8 * 得到的结果为: * int: 1 * float: 2.0 * double:3.0 * String:4 * line: 5 6 7 8 */ Scanner sc = new Scanner(System.in); System.out.println("int:"+sc.nextInt()); System.out.println("float:"+sc.nextFloat()); System.out.println("double:"+sc.nextDouble()); System.out.println("String:"+sc.next()); System.out.println("line:"+sc.nextLine()); }