开发者

adding char array to HashSet

I have a HashSet of Character and I am trying to do:

Collections.addAll(mySet, test.toCharArray());
        myS开发者_StackOverflowet.addAll(test.toCharArray());

why is it saying it is not applicable? How do I fix this?


Because toCharArray() yields a char[], not a Character[]. Java generics don't work with primitives, so I guess you need to add each element manually.


I just stumbled upon another open source library that provides a high performance collections for primitives -- HPPC http://labs.carrotsearch.com/hppc.html

They were motivated by performance issues on autoboxing, and well, having primitives directly supported in collections.

Looks pretty good.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜