DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Hybrid View

  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.

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links