- package com.itheima;
- import java.util.Scanner;
- public class ScannerDemo {
- public static void main(String[] args) {
- // String s = "aa,12,3.4";
- Scanner scanner = new Scanner(System.in).useDelimiter(",");
- System.out.println(scanner.next());
- System.out.println(scanner.nextInt());
- System.out.println(scanner.nextFloat());
- }
- }
复制代码 为什么我用s代替System.in就可以分割字符,而我用键盘录入却总是少1个呢? |