Results 1 to 2 of 2
Thread: Comparable interfaces
- 04-12-2012, 05:08 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 1
- Rep Power
- 0
Comparable interfaces
Hi there, i need a lot of help with this one. I need to create a list of objects that are actually the files in a computer system. Then i need to have them compared to one another to get the biggest ones and place them in an ArrayList. The trick is i have to specify the amount of files i want in the list and if i reach that number it is suppose to begin dropping the smallest files until I'm left with the biggest in the whole system.
- 04-12-2012, 10:42 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Re: Comparable interfaces
Don't use a List; use a Map<Long, List<String>> where the key is the size of the file(s) and the value is a List of file names with that size. Make your Map a SortedMap (e.g. a TreeMap) so it is easy to drop the smallest element(s) from the map.
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
Similar Threads
-
Comparable interface
By diamonddragon in forum New To JavaReplies: 17Last Post: 02-01-2012, 01:07 AM -
Comparable checks
By Billywizz in forum New To JavaReplies: 6Last Post: 12-07-2011, 05:37 AM -
Comparable and Comparator
By jeanjiang in forum New To JavaReplies: 7Last Post: 04-23-2011, 08:59 AM -
Comparable Interface
By Yelrubk in forum New To JavaReplies: 3Last Post: 04-28-2010, 03:46 PM -
Using Comparable and Comparator interfaces
By barney in forum New To JavaReplies: 1Last Post: 08-07-2007, 08:10 AM
Bookmarks