10.11 day 8
如下代码的输出?
package Test; public class Test { private static void test(int[] arr) { for (int i = 0; i < arr.length; i++) { try { if (arr[i] % 2 == 0) { throw new NullPointerException(); } else { System.out.print(i); } } finally { System.out.print("e"); } } } public static void main(String[]args) { try { test(new int[] {0, 1, 2, 3, 4, 5}); } catch (Exception e) { System.out.print("E"); } } }
eE
解释:
finally中的语句一定会执行,catch捕获到异常后程序结束
2.
java关键字都是小写的
3.
再来记忆一下:
1.Hashtable是一个散列表,它存储的内容是键值对(key-value)映射。
2.Hashtable的函数都是同步的,这意味着它是线程安全的。它的key,value都不可以为null
3.
HashTable直接使用对象的hashCode
HashMap:
(1)由数组+链表组成的,基于哈希表的Map实现,数组是HashMap的主体,链表则是主要为了解决哈希冲突而存在的
(2)不是线程安全的,HashMap可以接收为null的键和值
(3)HashMap重新计算hash值
Hashtable,HashMap,Properties:
Properties类继承了Hashtable类,而Hashtable 类继承Dictionaryl类