Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
151 views
in Technique[技术] by (71.8m points)

java - 如何在Java中将Map转换为List?(How to convert a Map to List in Java?)

What is the best way to convert a Map<key,value> to a List<value> ?

(将Map<key,value>转换为List<value>的最佳方法是什么?)

Just iterate over all values and insert them in a list or am I overlooking something?

(只是遍历所有值并将它们插入列表中,还是我忽略了什么?)

  ask by Javaa translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
List<Value> list = new ArrayList<Value>(map.values());

假设:

Map<Key,Value> map;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...