zoukankan      html  css  js  c++  java
  • Java | 基础归纳 | Map.Entry<String, String>

     1 public class Test {
     2     private static Map<String,String> student;
     3     
     4     private static void init() {
     5         student = new LinkedHashMap<String,String>();
     6         student.put("16010001", "tom");
     7         student.put("16010002", "tony");
     8         student.put("16010003", "j");
     9         student.put("16010004", "yy");
    10     }
    11     
    12     public static void main(String[] args) {
    13         init();
    14          String key = null;
    15          Scanner stdin = new Scanner(System.in);
    16          System.out.println("Choose a SchoolId:");
    17          for(Map.Entry<String, String> stu:student.entrySet()) {
    18              System.out.println(stu.getKey()+"	" + stu.getValue());
    19          }
    20          while(key == null) {
    21               key = stdin.nextLine();
    22               if (student.get(key) == null) {
    23                     System.out.println("Invalid choice!");
    24                     key = null;
    25                 }
    26          }
    27          
    28          System.out.println("Success!");
    29     }
    30 }
  • 相关阅读:
    MongoDB 基础API使用
    MongoDB -- JAVA基本API操作
    Docker数据管理
    Docker容器的简单使用
    Docker
    Centos 7.3 镜像制作
    Fuel部署OpenStack
    Fuel
    Ceph添加、删除osd及故障硬盘更换
    ceph常用命令
  • 原文地址:https://www.cnblogs.com/jj81/p/10040203.html
Copyright © 2011-2022 走看看