Java中运行程序时没有报错在console中不能输入

帆影匆匆 帆影匆匆 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

import org.junit.Test;
public class test_map_1 {




@Test
public void test_1(){
HashMap<String,Integer> map=new HashMap<String,Integer>();
System.out.println("请输入学生的数量");
Scanner in=new Scanner(System.in);
int k=in.nextInt();
String[] str=new String[2];

System.out.println("请输入学生的姓名和成绩");
String line=in.nextLine();
str=line.split(" ");
map.put(str[0], Integer.parseInt(str[1]));

Set<Map.Entry<String,Integer>> set1=map.entrySet();
for(Map.Entry<String,Integer> o :set1){
System.out.println(o.getKey()+"------->"+o.getValue());
}

求问为啥这程序也没报错,但是在运行 System.out.println("请输入学生的数量"); 这条语句之后,不能再console控制台中输入任何的数据,键盘也没坏,
...全文
评论 2
收藏 已收藏
分享
返回顶部
帆影匆匆
Eclipse 58,440 成员 49,457 内容