File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What is use of Backed Collection in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What is use of Backed Collection in java" Watch "What is use of Backed Collection in java" New topic

What is use of Backed Collection in java

Prateek Kumar Singh

Joined: Jan 21, 2011
Posts: 29

can any body elaborate that what is use of Backed Collection in java.

Prateek Singh
Jelle Klap

Joined: Mar 10, 2008
Posts: 1950

Backed collections, like the ones you get from SortedSet's headSet(), subSet() and tailSet() methods, or SortedMap's headMap(), subMap(), and tailMap()'s methods, are intented as views of a particular section of the larger collection - according to their API documentation. These view collections are conceptually similar to updatable database views, and offer some of the same advantages. Their memory footprint is small, because no data is actually duplicated, as all references point to the same objects, and they can logically partition a large collection making it easier to work with relevant data. A "write-through" view isn't always what you want, though, so it's very important to be aware of that behavior. Some times you actually need a defensive copy of a collection, and directly exposing the results of the methods mentioned earlier would of course violate that. Another kind of backing is what you get when using Arrays.asList() where the returned List is backed by an array.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
I agree. Here's the link:
subject: What is use of Backed Collection in java
jQuery in Action, 3rd edition