• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Collections

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am preparing SCJP 1.5. I have doubt in 7th Unit. I need explanation of Sorted and Ordered
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
unordered is a type of collection in which the order in which elements will be retrieved is not predictable.

as far as I know ordered means that the elements will be retrieved in the order in which they are added to the collection

sorted means that the new added element will be added to its appropriate location according to the sorting criteria.


I have only basic knowledge of collections so I may be wrong....
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ordered vs. unordered: An ordered collection is a collection which holds its elements in a defined order (a List, for example, is an ordered collection). An unordered collection holds elements, but not in a defined order. It is like a bag with things in it - the things are just jumbled up together in the bag, and not in any specific order. A Set is an example of an unordered collection.

Sorted vs. unsorted: When the elements of an ordered collection are placed in a specific, defined order (for example, strings in alphabetical order), then the collection is sorted. Ofcourse, only ordered collections can be sorted.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic