且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否有相当于java.util.Properties的集合?

更新时间:2022-03-28 05:24:15

是,属性类本身提供了转换的访问器方法:

yes, the Properties class itself provides accessor methods for convertions:

public Set< Map.Entry> entrySet

public Set<Map.Entry> entrySet()

返回此地图中包含的映射的KeySet视图。该集合由映射支持,因此对映射的更改反映在集合中,反之亦然。如果在迭代集合的过程中修改映射(除非通过迭代器自己的remove操作,或者通过迭代器返回的映射条目上的setValue操作),迭代的结果是未定义的。集合支持元素删除,它通过Iterator.remove,Set.remove,removeAll,retainAll和clear操作从映射中删除相应的映射。它不支持add或addAll操作。

Returns a KeySet view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

public Set< K> keySet()

返回此映射中包含的键的KeySet视图。该集合由映射支持,因此对映射的更改反映在集合中,反之亦然。如果在迭代集合的过程中修改映射(除非通过迭代器自己的remove操作),迭代的结果是未定义的。集合支持元素删除,它通过Iterator.remove,Set.remove,removeAll,retainAll和clear操作从映射中删除相应的映射。它不支持add或addAll操作。

Returns a KeySet view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

可以使用 elements()枚举属性