Results 1 to 2 of 2
  1. #1
    louie is offline Member
    Join Date
    Apr 2012
    Rep Power

    Default 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.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default 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,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Comparable interface
    By diamonddragon in forum New To Java
    Replies: 17
    Last Post: 02-01-2012, 01:07 AM
  2. Comparable checks
    By Billywizz in forum New To Java
    Replies: 6
    Last Post: 12-07-2011, 05:37 AM
  3. Comparable and Comparator
    By jeanjiang in forum New To Java
    Replies: 7
    Last Post: 04-23-2011, 08:59 AM
  4. Comparable Interface
    By Yelrubk in forum New To Java
    Replies: 3
    Last Post: 04-28-2010, 03:46 PM
  5. Using Comparable and Comparator interfaces
    By barney in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 08:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts