I have an array of nodes, which is 4000 elements large. During my traversal algorithm, each node will meet other node. I want to create a HashSet
to store each node it meets on the way. Each node should has their own HashSet
.
Does Java have a construct like this?
<Hashset<Node>>[] res = new Hashset<Node>[4000];
Yes. A generic type parameter may itself be generic , and thus the following is valid:
ArrayList<HashSet<Node>> res=new ArrayList<HashSet<Node>>();
Note capitalization in the name of java.util.HashSet
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.