nagul samy wrote:Hello Team,
What is the default order of Set Interface in Java as it is not an ordered Collection. For example if add five elements in HashSet on which order it will print.
First, there is nothing in the document that states that the Set interface is unordered -- for example, the TreeSet implementation of the Set interface is ordered.
As for the HashSet, the definition of "unordered" means that it is without an order, and that includes a "default order". If you run a
test, you may get an order printed, but that could change on a different version of the JVM, which has a different implementation.
Henry