The advance of Java -- Set, LinkedList, Map(Day03)

1. Comparable:

A class implements Comparable, which means it own rule of comparison, like TreeSet. It need the elements we put must implements comparable interface and remember add  generics.

2. Comparator:

If we want to temporarily formulate a rule of comparison, For example, Collections.sort() need to cast a instance of parameter type of Comparator, and we can handle it with lambda.

3. LinkedList:(FIFO)

add, delete, alter, check

4. Map:

①HashMap: out of order, no repeat

Method: put(key, value); get(key); containsKey(key); containsValue(value); keySet(); entrySet(); size(); clear()

*put has return value, so it can save old value when we replace.

②The relationship between HashSet and HashMap: their infrastructure of implements is by HashMap

③HashCode & equals: when map call put method, it will find the HashCode of Key, if they are same; then compared with equals.

④TreeMap: order, no repeat

⑤LinkedHashMap: order, like LinkedList, no repeat

⑥WeakHashMap: week reference, when we call the System.gc(), they will be callback.

⑦IdentityHashMap: no repeat. Judge by '==' rather than equals.

5. Properties:

Attribute class, it can store Key-Value into the file, Similarly,they can also read Key-Value into memory, We will always see the file named .properties in our future projects. 

Method: p.get(); p.set(); p.load(); p.store();

Properties p =new Properties();
		/*p.setProperty("Java", "100");
		p.setProperty("key", "value");
		p.store(System.out, "Chinese");
		File f = new File("d:/a.properties");
		p.store(new FileOutputStream(f), "Score");*/
		File f = new File("d:/a.properties");
		p.load(new FileInputStream(f));;
		System.out.println(p.get("Java"));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值