Java – how do I get the hashtable value as an ArrayList?
•
Java
Hashtable
How to convert its value to:
ArrayList <Word> arr
thank you.
Solution
Use the ArrayList constructor that requires a collection
ArrayList<Word> arr = new ArrayList<Word>(hw.values());
Then each value in the hashtable will be in the new ArrayList
You can find documentation on constructors in the JavaDocs
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码