Programming, Object Oriented, Java.
insertion order of elements while TreeSet orders its elements by their natural order or comparator(if supplied). Now if we write a method that accepts a collection and prints its elements, the actual object (ArrayList or TreeSet) at runtime will decide the behavior of this method. Polymorphic print