如何从Array中添加SortedSet项?

我有这样定义的SortedSet:
SortedSet<RatedMessage> messageCollection = new TreeSet<RatedMessage>(new Comp());

我有一个RatedMessage []数组

我必须使用数组,因为集合错过了序列化功能,现在我需要重新构建它.

有没有一种快速方法可以将数组中的所有项目再次添加到集合中?

解决方法

Collections.addAll(messageCollection,array);

功能与迈克尔的答案完全相同,但正如javadoc所说:

Adds all of the specified elements to the specified collection. Elements to be added may be specified individually or as an array. The behavior of this convenience method is identical to that c.addAll(Arrays.asList(elements)),but this method is likely to run significantly faster under most implementations.

相关文章

背景 阿里java开发规范是阿里巴巴总结多年来的最佳编程实践,...
# 前言 在面试这一篇我们介绍过[CountDownLatch和CyclicBarr...
多线程编程是每一个开发必知必会的技能,在实际项目中,为了...
背景 在我们系统中有这么一个需求,业务方会通过mq将一些用户...
# 前言 为了更好的进行开发和维护,我们都会对程序进行分层设...
前言 关于动态代理的一些知识,以及cglib与jdk动态代理的区别...