• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alphabetizing an ArrayList

 
J. Floyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to alphabetize the contents of an arrayList by last name. I am completely stuck. Each element in the arrayList contains a string for first name, last name, address, city, state, zip, phone, fax. There are also two optional strings for cell and email.

Here is my code:


The program is not working. I commented out the Collections line and kept getting this as my output: [[Ljava.lang.Object;@13d93f4].

Any help would be greatly appreciated.

Thank you.
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to create a custom Object to store the individual properties. Then you can use a Comparator to sort on a specific property. Something like:

Sorting People by Name

Or you may find the Bean Comparator helpfull since you won't have to write a custom Comparator.
 
J. Floyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I ended up getting it to work in the SQL statement that retrieves the database. I appreciate your help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic