What is the Backed Collection in Java?

These methods return a Backed Collection, since a change in one collection affects another collection. [type of recording process]

headSet(e, b)     Returns a subset ending at element e and exclusive of e

headMap(k, b)     Returns a submap ending at key k and exclusive of key k

tailSet(e, b)     Returns a subset starting at and inclusive of element e

tailMap(k, b)     Returns a submap starting at and inclusive of key k

subSet(s, b, e, b)    Returns a subset starting at element s and ending just before element e

subMap(s, b, e, b)    Returns a submap starting at key s and ending just before key e

Then what's the difference with the method Arrays.asList()? The method copies the array to the list. The API says "changes to the returned list" write through "to the array and vice versa."

So is this also a collection with support? If so, then the toArray () method in the List interface is also a fallback collection?

Is there any other method, for example Arrays.asList(), that allows writing through? How can I find out if a method allows writing through or not, only by seeing the method signature?

+3
source share
1 answer

, Arrays.asList , , , Collection.toArray , .

, , , - . "", "" .. - List.subList, , Collections.newSetFromMap , .

+7

All Articles