HashMap集合键是Student值是String的案例

来源:互联网 发布:编程有什么用 编辑:程序博客网 时间:2024/05/17 22:42
    /*
         * 集合框架(HashMap集合键是Student值是String的案例) A:案例演示
         * HashMap集合键是Student值是String的案例
         * 键是学生对象,代表每一个学生
         * 值是字符串对象,代表归属地
         *
         */
        HashMap<Student, String> hm =new HashMap<>();
        hm.put(new Student("张三",23),"上海" );
        hm.put(new Student("张三",23),"北京" );
        hm.put(new Student("王五",23),"南京" );
        hm.put(new Student("赵六",23),"无锡" );
        System.out.println(hm);