Results 1 to 5 of 5
  1. #1
    i4ba1 is offline Member
    Join Date
    Aug 2008
    Posts
    13
    Rep Power
    0

    Question Problem arraylist result when use Collections.sort

    Hai all,

    I have a problem when i use Collections.sort. i sort the arraylist using Collections.sort(myArrayList). the problem is in the result. the result is
    [TRUE, FALSE, a, aa, b, bb, c]. why the result showing the TRUE and FALSE?. because in my data there is no TRUE and FALSE. can you help to find out what cause this problem?.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by i4ba1 View Post
    Hai all,

    I have a problem when i use Collections.sort. i sort the arraylist using Collections.sort(myArrayList). the problem is in the result. the result is
    [TRUE, FALSE, a, aa, b, bb, c]. why the result showing the TRUE and FALSE?. because in my data there is no TRUE and FALSE. can you help to find out what cause this problem?.
    Without code or context, I'm not sure how you can expect us to even guess.

  3. #3
    i4ba1 is offline Member
    Join Date
    Aug 2008
    Posts
    13
    Rep Power
    0

    Default

    Here is link of my code: Paste Code

    and the problem of result in line 792

    i try to update data. and after update done the data will put into JList and need to be sorted.
    so i use Collection.sort(kata).

    sorry if my code to much

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by i4ba1 View Post
    Here is link of my code: Paste Code

    and the problem of result in line 792

    i try to update data. and after update done the data will put into JList and need to be sorted.
    so i use Collection.sort(kata).

    sorry if my code to much
    Line 792? Yeah, it's definitely too much. You need to do some detective work to isolate the bug for there definitely is a bug in your code. Using println statements or a debugger will help. If you're still stuck, then create and post an SSCCE. The link will tell you what's needed.

  5. #5
    HarithaReddy is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Default

    Collections.sort would never return elements that are not present in the list earlier.
    And FALSE would come before TRUE in the string you typed, if the collection has been sorted !

Similar Threads

  1. Arraylist problem Sort Date , alphabetically
    By ob3lix in forum New To Java
    Replies: 1
    Last Post: 11-26-2010, 03:55 PM
  2. ArrayList sort
    By Dipke in forum New To Java
    Replies: 1
    Last Post: 08-23-2010, 01:01 PM
  3. Collections.sort()
    By collin389 in forum Advanced Java
    Replies: 11
    Last Post: 12-31-2009, 11:03 AM
  4. Using Merge Sort to sort an ArrayList of Strings
    By coldfire in forum New To Java
    Replies: 3
    Last Post: 03-13-2009, 01:03 AM
  5. Collections Sort
    By senthil_jr in forum Advanced Java
    Replies: 2
    Last Post: 06-04-2008, 08:11 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
  •