Java编程Best Practice
Map遍历 Best Practice:
Map<K, V> map = new HashMap<K, V>();
// for 比 while 效率高
// JDK 1.4
for (Iterator<Entry<K, V>> entryKeyIterator = map.entrySet().iterator(); entryKeyIterator.hasNext(); ) {
Entry<K, V> item = entryKeyIterator.next();
K key = item.getKey();
V value = item.getValue();
}
// JDK 1.5
for (Map.Entry<K, V> item : map.entrySet()) {
K key = item.getKey();
V value = item.getValue();
}
see: keySet与entrySet遍历HashMap性能差别
List类型数组 定义:
List<?>[] listArray= new List<?>[n];
File 的 getPath, getAbsolutePath, getCanonicalPath 的不同