HashMap集合的使用
来源:互联网 发布:37大闹天宫进阶数据 编辑:程序博客网 时间:2024/05/16 06:21
学生与就读的学校
public class student {
private Stringname; //定义学生名字
private Stringschool; //定义学校
public student(String name, String school) {
this.name = name;
this.school = school;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSchool() {
return school;
}
public void setSchool(String school) {
this.school = school;
}
@Override
public String toString() {
return "姓名:" +name + ",就读学校:" +school+"\n";
}
}
第二部分:
public class demo {
public static void main(String[] args) {
// TODO Auto-generated method stub
student s1=new student("张三","清华大学");
student s2=new student("李四","北京大学");
student s3=new student("王五","香港大学");
Map m=new HashMap();
m.put("三", s1);
m.put("四", s2);
m.put("五", s3);
System.out.println("键集:"+m.keySet());
System.out.println("值集:"+m.values());
System.out.println("键-值对集合:"+m);
if (m.containsKey("三")) {
System.out.println(m.get("三"));
} else {
System.out.println("张三不见了!");
}
m.remove("三");
System.out.println(m.get("三"));
}
}
- HashMap集合的使用
- java的集合 Map集合,HashMap集合,LinkedHashMap集合 使用方式及遍历
- HashMap集合的遍历
- JAVA 集合Map的简单使用(HashMap)
- 集合类的学习--HashMap
- HashMap集合的三种迭代方法
- HashMap集合的自定义实现
- 集合框架-集合的嵌套遍历(HashMap嵌套HashMap)
- 集合框架-HashMap集合的案例
- HashMap集合与TreeMap集合的比较
- 集合框架_HashMap集合嵌套HashMap集合的案例
- 集合框架_ArrayList集合嵌套HashMap集合的案例
- HashMap集合
- HashMap集合
- HashMap集合
- HashMap集合
- 集合-HashMap
- (11) java集合 ---- LinkedHashMap和HashMap等Map的比较使用以及 LinkedHashMap的实现原理
- iOS开发之旧版本Xcode下载
- MyBatis之整合Spring(Dao和Mapper两种方式)
- 关于JS循环Table
- 深度信念网络
- java 生成验证码
- HashMap集合的使用
- @Resource
- sortedArrayUsingComparator
- RNN循环神经网络
- gcc 用法
- LeetCode c语言-Generate Parentheses和买票找零问题
- 【学习摘记】马士兵bbs初级版_课时14-15_login权限控制:session的典型用法
- Java实现——统计文件中字符串出现次数
- 通过http协议导出excel