Automatic indexed sorted array maintained by Java?
Is there a feature in java by which I define an array as to keep it in a sorted fashion which will let me insert or remove an element in this array. This is to avoid expensive re-sort开发者_开发百科 when an element is to be added or removed?
If you are storing Objects in your Array which are not duplicated and can be compared using a Comparable, you could use a TreeSet which will keep your elements in order at all times.
精彩评论