1、知识点
HashMap,泛型,Collections类
2、典题展示
(1)父类
package cn.xtjy.nj.throughmap;
public abstract class Pet {
protected String name;
public Pet() {
super();
// TODO Auto-generated constructor stub
}
public Pet(String name) {
super();
this.name = name;
}
public String getName(){
return this.name;
}
@Override
public String toString() {
return "Pet [name=" + name + "]";
}
}
(2)子类
package cn.xtjy.nj.throughmap;
public class Dog extends Pet {
private String strain;
public String getStrain(){
return this.strain;
}
public Dog() {
super();
// TODO Auto-generated constructor stub
}
public Dog(String name,String strain) {
super(name);
this.strain = strain;
// TODO Auto-generated constructor stub
}
public String getName(){
return super.getName();
}
@Override
public String toString() {
return "Dog [name="+name+",strain=" + strain + "]";
}
}
(3)测试类
测试类1:
package cn.xtjy.nj.throughmap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class TestDog {
public static void main(String[] args) {
Dog duoduo = new Dog("多多","拉布拉多");
Dog meimei = new Dog("美美","阿拉斯加雪橇犬");
Dog huanhuan = new Dog("欢欢","中华田园犬");
Dog xixi = new Dog("喜喜","秋田犬");
//1、创建HashMap集合
Map list = new HashMap();
//2、存储Dog对象
list.put(duoduo.getName(), duoduo);
list.put(meimei.getName(), meimei);
list.put(huanhuan.getName(), huanhuan);
list.put(xixi.getName(), xixi);
//3、使用迭代器
/**
* Set set = list.keySet();
* Iterator it = set.iterator();
*/
Iterator it = list.keySet().iterator();
while(it.hasNext()){
String key = (String)it.next();
System.out.println(key+"\t"+list.get(key));
}
}
}
测试类2
package cn.xtjy.nj.throughmap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class TestMap {
public static void main(String[] args) {
Dog duoduo = new Dog("多多","拉布拉多");
Dog meimei = new Dog("美美","阿拉斯加雪橇犬");
Dog huanhuan = new Dog("欢欢","中华田园犬");
Dog xixi = new Dog("多多","秋田犬");
//1、使用泛型定义集合
Map<String,Dog> map = new HashMap<String,Dog>();
map.put(duoduo.getName(),duoduo);
map.put(meimei.getName(),meimei);
map.put(huanhuan.getName(),huanhuan);
map.put(xixi.getName(),xixi);
//2、增强for循环遍历所有信息
Set set = map.keySet();
for(Object key:set){
String key1 = (String)key;
System.out.println(map.get(key1));
}
}
}
3、关于做笔记的几点改进
(1)目前情况:
首要问题,手写笔记用时过多,每天约占2节课时间。导致敲代码和看书预习时间被压缩。
次要问题,每次写CSDN博客使用的时间也较多,尤其是在校期间的自习期间更新时,因思路慢而容易造成内心焦躁。
(2)原因分析:
第一,手写笔记过于求全面,甚至对PPT上许多现成的普通知识点也进行誊写。
第二,隔天甚至隔几天更博客,容易因知识生疏而造成思路组织缓慢。
第三,白天在校自习期间,每节自习课的学习目标时常模糊,因而容易产生拖沓和时间不足的问题。时间分配有带优化。
(3)改进措施
第一,关于手写笔记:本着笔记乃为帮助自己在复习时提纲挈领之用,只记学习和复习思路,记总结性的,记知识点之间的联系和比较,记老师刻意强调的。
第二,关于CSDN博客:就一个要求,当天博客当天更。不苛求完美!
第三,关于自习课学习目标:每天围绕两件事-复习当天和准备第二天。