5月4日学习内容

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 hm = new HashMap();//        创建对象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 keySet = hm.keySet();for(Integer key : keySet){Student value = hm.get(key);System.out.println("姓名:"+value.getName()+","+"年龄:"+value.getAge());}System.out.println("--------------------");//    方法二,键值对对象找键和值Set> entrySet = hm.entrySet();for(Map.Entry 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> array= new ArrayList>();//  创建HashMap集合HashMap hm1 = new HashMap();HashMap hm2 = new HashMap();HashMap hm3 = new HashMap();
//        向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 hm : array){Set keySet = hm.keySet();for (String key : keySet){String value = hm.get(key);System.out.println(value);}}}
}

3.了解了File类

4.完成每日目标10集

5.复习了python爬虫selenium;


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部