• 2021-04-14
    Scanner sc=new Scanner( )
  • 1

    内容

    • 0

      语句“Scanner scan=new Scanner(System.in);”功能是()

    • 1

      下列__________说法是正确的?I:File file = new File("input.txt");try (Scanner input = new Scanner(file)) { String line = input.nextLine();}II:try (File file = new File("input.txt"); Scanner input = new Scanner(file);) { String line = input.nextLine();}III:File file;try (file = new File("input.txt"); Scanner input = new Scanner(file);) { String line = input.nextLine();}IV:File file;Scanner input;try (file = new File("input.txt"); input = new Scanner(file);) { String line = input.nextLine();} A: I B: II C: III D: IV

    • 2

      (2-5)下面程序段可从命令行窗口中获取用户输入的整型值。[br][/br] Scanner sc=new Scanner(System.in); int x=sc.nextDouble();

    • 3

      测一测(Java程序输入输出)假定 Scanner sc=new Scanner(System.in);则以下哪一项用于获取用户输入的字符串? A: sc.next() B: sc.nextInt() C: sc.nextFloat() D: sc.next().charAt(0)

    • 4

      以下哪个语句是输入语句()。 A: Scanner scan = new Scanner(System.in); B: System.out.println("请输入用户名:"); C: msg.setUserName(scan.next());