1.进行了HashMap集合的练习
Student.java
-----------------------------------------------
public class Student {
private int Age;
private String Name ;
public Student() {
}
public Student(String Name, int Age) {
this.Name = Name;
this.Age = Age;
}
public int getAge() {
return Age;
}
public void setAge(int age) {
this.Age = age;
}
public String getName() {
return Name;
}
public void setName(String name) {
this.Name = name;
}
}
HashMapDemo.java
--------------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class HashMapDemo {
public static void main(String[] args) {
HashMap<Integer,Student> hm = new HashMap<Integer,Student>();
// 创建对象
Student s1 = new Student("张文雨",18);
Student s2 = new Student("张文晴",12);
Student s3 = new Student("张文川",8);
// 传入对象
hm.put(1,s1);
hm.put(2,s2);
hm.put(3,s3);
// 遍历
// 方法一,键找值
Set<Integer> keySet = hm.keySet();
for(Integer key : keySet){
Student value = hm.get(key);
System.out.println("姓名:"+value.getName()+","+"年龄:"+value.getAge());
}
System.out.println("--------------------");
// 方法二,键值对对象找键和值
Set<Map.Entry<Integer,Student>> entrySet = hm.entrySet();
for(Map.Entry<Integer,Student> me :entrySet){
Integer key = me.getKey();
Student value = me.getValue();
System.out.println("姓名:"+value.getName()+","+"年龄:"+value.getAge());
}
}
}
2.学习了ArrayList集合与HashMap集合的嵌套
ArraList嵌套HashMap.java
--------------------------------------------
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
public class ArrayList嵌套HashMap {
public static void main(String[] args) {
// 创建ArrayList集合
ArrayList<HashMap<String,String>> array= new ArrayList<HashMap<String,String>>();
// 创建HashMap集合
HashMap<String,String> hm1 = new HashMap<String,String>();
HashMap<String,String> hm2 = new HashMap<String,String>();
HashMap<String,String> hm3 = new HashMap<String,String>();
// 向HashMap中添加元素
hm1.put("1","1");
hm1.put("2","2");
hm2.put("3","3");
hm2.put("4","4");
hm3.put("5","5");
hm3.put("6","6");
// 向ArrayList中添加HashMap集合
array.add(hm1);
array.add(hm2);
array.add(hm3);
// 遍历
for(HashMap<String,String> hm : array){
Set<String > keySet = hm.keySet();
for (String key : keySet){
String value = hm.get(key);
System.out.println(value);
}
}
}
}
3.了解了File类
4.完成每日目标10集
5.复习了python爬虫selenium;