为什么运行失败了,我在eclipse可以运行

为什么运行失败了,我在eclipse可以运行

import java.util.HashMap;

import java.util.Iterator;

import java.util.Map;

import java.util.Map.Entry;

import java.util.Scanner;

import java.util.Set;


public class FootballDemo {

public static void main(String[] args) {

//定义HashMap的对象并添加数据

Map <String,String> country=new HashMap <String,String> ();

Scanner ac=new Scanner(System.in);

        int i=0;

        while(i<3) {

       System.out.println("年份");

       String key=new Scanner(System.in).next();

       System.out.println("国籍");

       String value=new Scanner(System.in).next();

       country.put(key, value);

       i++;

       }

       

//使用迭代器的方式遍历

       System.out.println("通过迭代器遍历输出value");

       Iterator<String> it=country.values().iterator();

       while(it.hasNext()) {

       System.out.println(it.next()+" ");

       }

       

//使用EntrySet同时获取key和value

       System.out.println("通过entrySet输出key和value值");

       Set <Entry<String,String>> entrySet=country.entrySet();

       for(Entry<String,String>entry:entrySet) {

       System.out.print(entry.getKey()+"-");

       System.out.println(entry.getValue());

       }

}


}


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
吃吃吃鱼的猫 2019-06-07 16:56:14

同学你好,在平台上可能会因为导包等原因造成运行失败。

建议同学将代码在自己的运行环境中运行哦~

如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师