public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String nextLine = scanner.nextLine();
int num = 1;
while (nextLine != null && !nextLine.equals("")&&(num < 2)) {//num < 2,想输入几行敲回车结束,这里就<几
if (!nextLine.equals("")){
num++;
}
String[] str = nextLine.split(",");//String[] str = nextLine.split(" ");可以替换成空格或者别的
nextLine = scanner.nextLine();
}
}
主要针对的是ACM模式的笔试编程题的多行输入。