please, help me with sort object with date and name?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: please, help me with sort object with date and name?

  1. #1
    Join Date
    Jun 2008
    Posts
    3

    please, help me with sort object with date and name?

    Please, i am new for here, and need much your help. Because i need sort a arraylist with object. my object has a date and a name, i need know how make to compare two dates in comparator for sort it.

    example:

    class Client(){
    private String Name=null;
    private Date date = null;
    }

    somebody can help me, please

  2. #2
    Join Date
    Jun 2008
    Posts
    1
    use Comparator or goto techfaq360.com/java_interview_questions.jsp?qid=379 for code example
    Last edited by satyadas; 06-06-2008 at 07:37 AM.

  3. #3
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    make the class implement the Comparable interface and create a way in which you are going to order the objects of the class. By name and then break ties by some dateorder? I expect you would want to use the built-in sorting capabilities of objects of the String and Date abstract data types.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center