zoukankan      html  css  js  c++  java
  • 0926-----homework(1)

     

     

     1 /**
     2   *homework0926
     3   *@author:kai li
     4   */
     5 package com.kai.li.homework0926;
     6 import java.util.List;
     7 import java.util.ArrayList;
     8 import java.util.Arrays;
     9 import java.util.HashMap;
    10 import java.util.Map;
    11 import java.util.Scanner;
    12 /**
    13   *
    14   */
    15 public class HomeWork0926{
    16     public static void main(String[] args)throws Exception{
    17         
    18         /**
    19           *question one
    20           */
    21 
    22         /*create data sourse*/
    23 
    24         List<String> keyList=Arrays.asList("1930","1934","1938","1950","1954","1958","1962","1966","1970","1974","1978","1982","1986","1990","1994","1998","2002","2006","2010","2014");
    25         List<String> valueList=Arrays.asList("乌拉圭","意大利","意大利","乌拉圭","西德","巴西","巴西","英格兰","巴西","西德","阿根廷","意大利","阿根廷","西德","巴西","法国","巴西","意大利","西班牙","德国");
    26         Map<String,String> footballMap=new HashMap<>();
    27         for(int i=0;i<keyList.size();i++){
    28             footballMap.put(keyList.get(i),valueList.get(i));
    29         }
    30 
    31         /*query with years*/
    32          
    33         System.out.print("请输入年份:");    
    34         Scanner scanner=new Scanner(System.in);
    35         String strKey=scanner.nextLine();
    36         if(!footballMap.containsKey(strKey))
    37             System.out.println("没有举办世界杯");
    38         else
    39             System.out.println("世界杯冠军是: "+footballMap.get(strKey));
    40 
    41         /*query with countrys */
    42         
    43         System.out.print("请输入国家名称:");
    44         String strValue=scanner.nextLine();
    45         if(!footballMap.containsValue(strValue))
    46             System.out.println(strValue+"没有得过世界杯的冠军");
    47         else{
    48             System.out.println(strValue+"得冠军年份是:");
    49             footballMap.keySet().stream().filter(i->strValue.equals(footballMap.get(i))).sorted().forEach(System.out::println);    //filter the data then sorted then println
    50         }
    51     }
    52 }
    88 }
  • 相关阅读:
    jquery 中 $.map 的使用方法
    数据库 'MessageManage' 的事务日志已满。若要查明无法重用日志中的空间的原因,请参阅 sys.databases 中的 log_reuse_wait_desc 列。
    Post提交
    MD5加密、时间戳转换、base64算法加密、解密
    C#中timer类的用法
    软件项目版本号的命名规则及格式
    SQL Server数据库脚本备份与还原
    C# Out,Ref 学习总结
    在线工具
    构造和析构 的顺序
  • 原文地址:https://www.cnblogs.com/kaililikai/p/5913291.html
Copyright © 2011-2022 走看看