Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OOP 3: SortNames

 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question about the SortNames assignment. I have it all working except for the sort by last name, as I am finding out this is the hardest part of the project.
When you say don't modify the Strings in the ArrayList, does that mean I can't make a copy of the ArrayList and modify those Strings. Basically I was thinking of taking a copy of the list, chopping off the first name, sorting it, and then comparing it back to the old array to print it in order. Is there an easier way or a class or method I am missing?
Thanks,
Bill
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I found a slightly easier way, but I am still creating my own methods and not using something from the API.
Bill
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather than create a new list, the purpose of the assignment is for you to use the existing list and force a new way to do the sorting.� Take a look at an alternative way to call Collections.sort()
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Marilyn. I see it now. I have never used that method so it was nice to see how it works.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic