是否应该使用迭代器原始类型?

Iterator raw type should be used or not?

我想知道这句话之间的区别:

Iterator<String> it = map.values().iterator();

还有这条语句:

Iterator it = map.values().iterator();

还有为什么分隔语句是一个好习惯:

Collection<Map.Entry<String,Customer>> entry_set = map.entrySet();
Iterator<Map.Entry<String,Customer>> entryIterator = entry_set.iterator();

It is always a good practice to define generic type for the iterator so that you can extract the item it retrieves without casting.

This also helps in compile-time type safety of the code.

我更喜欢使用 Iterator<String> it