Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
java中是否有一个功能,我通过它定义一个数组以使其保持排序方式,这将让我在这个数组中插入或删除一个元素。这是为了避免在添加或删除元素时进行昂贵的重新排序?
如果您在 Array 中存储不重复且可以使用 Comparable 进行比较的对象,则可以使用 TreeSet 来始终保持元素有序。