Tag Archive for Collections

Arrays.asList() – Why You Should Wrap It

oh noes!
I was trying to get the difference of two lists of files when a wild UnsupportedOperationException appeared!

My code looked a lil’ something like this:

List<File> listOfOtherFiles = Arrays.asList(otherDirectory.listFiles());
List<File> fileList = Arrays.asList(directory.listFiles());

The culprit: Arrays.asList(). Read more

Caching in Java with LRUMap

So you want to cache recently used values? Well, there’s LRUMap for that!

LRU stands for Least Recently Used. LRUMap uses the LRU algorithm to delete the least recently used value in the map (presumably full) to make space for the newest entry. Read more