java多个输入数据的处理方法
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
// 去掉字符串首尾空格
input = input.trim();
// 按照指定字符串分割某个字符串并以字符串数组形式返回
String[] temp = input.split(" ");
int m = Integer.parseInt(temp[0]);
int n = Integer.parseInt(temp[1]);
int o = Integer.parseInt(temp[2]);
int p = Integer.parseInt(temp[3]);
System.out.println(m);
System.out.println(n);
System.out.println(o);
System.out.println(p);
}
posted on 2021-05-25 09:51 Indian_Mysore 阅读(468) 评论(0) 收藏 举报
浙公网安备 33010602011771号