Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • I think if you want to rely on the ordering you have to use a List. Set/List issue has been discussed before. See this question. Commented Mar 30, 2011 at 6:23
  • That is not correct in general (as some answers in the discussion you are linking to are also stating). To eliminate all doubts: Have a look at TreeSet, it is a Set with a well-defined natural ordering, which you can very well rely on. Commented Mar 30, 2011 at 6:51
  • As to blaming, a Set offers no ways to obtain elements by an index. This is simply mandatory for JSF in order to locate the right rows during apply request values, validations, update model values and invoke application phases whenever a form with a table is been submitted. Commented Mar 31, 2011 at 16:33
  • new ArrayList<T>(Set <T>) would be a way ;-) Of course all assumptions about the order of elements are up to the implementation of the Set, but there might as well be usecases where a consistent ordering is not required. In my perception this would fill a gap between persistence (where sets are very useful) and presentation. Commented Apr 1, 2011 at 6:00