• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SortNames

 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am I understanding past conversations correctly, that we are, in fact, allowed to change the ArrayList of names, if by change we mean reorganize (sort differently)?
It would seem others liked using an Iterator. Are we supposed to use this? I just loop through the ArrayList with a simple for loop, getting one component after the other. Would it somehow be more efficient to use an Iterator?
Am I missing the point entirely, and we actually aren't supposed to reorganize the original ArrayList, but use rather some semi-complicated (and I'm sure not efficient) construct with an Iterator, Enumeration, etc. to display the names in the specified orders? Of course, that would seem to fly in the face of the "use Collections" requirement, but this wouldn't be the first time that the instructions would seem to be there more to fool us to do it wrong in order to be corrected - I don't think this is the case this time.
Oh yeah, and I'm really loving this Cattle Drive! It's the greatest!
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Originally posted by Dirk Schreckmann:
Am I understanding past conversations correctly, that we are, in fact, allowed to change the ArrayList of names, if by change we mean reorganize (sort differently)?


The Collections method that you use is allowed to change the ArrayList of names. You are not allowed to store the changed list in a new ArrayList.

It would seem others liked using an Iterator. Are we supposed to use this? I just loop through the ArrayList with a simple for loop, getting one component after the other.

Either way is acceptable.

... but this wouldn't be the first time that the instructions would seem to be there more to fool us to do it wrong in order to be corrected

You are welcome to suggest wording for any of the assignments which would make them clearer for future students. I believe that it was Matt who already has made a suggestion (which has been implemented) for this particular assignment, and you still have questions.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the clarifications.
I did read the previous suggestions for rewording the specifications, but the suggested changes appear to not have been made. It still says:
"Show the names sorted in order of first name and then by last name without modifying the strings or the ArrayList. ... Use the Collections class for sorting. "
So, the obvious confusion is: Which is it, don't modify the ArrayList and use Collections which changes the ArrayList or ... huh?"
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Load an ArrayList with Strings from a text file of names. Show the names sorted in order of first name and then by last name. Do not create a second list with the names in a different order. Use com.javaranch.common.TextFileIn to read the names. Use the Collections class for sorting. Your class will be called SortNames.


Better? Suggestions?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very clear. Of course if you still wanted to say something about not modifying the components of the ArrayList (especially when considering sorting by last name), that'd probably save one or twenty nitpicks.
Looks good.
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Load an ArrayList with Strings from a text file of names. Show the names sorted in order of first name and then by last name. Use com.javaranch.common.TextFileIn to read the names. Use the Collections class for sorting. Do not create a second list with the names in a different order. Do not store modified names in the ArrayList. Your class will be called SortNames.


Italicized section = proposed changes. Better? Suggestions?
[ May 03, 2002: Message edited by: Marilyn deQueiroz ]
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Definitely clarifies what a good portion of the student population have gotten hung up on.+
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps "do not modify the ArrayList or its contents except by using the Collections class to sort it."
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Load an ArrayList with Strings from a text file of names. Show the names sorted in order of first name and then by last name. Use com.javaranch.common.TextFileIn to read the names. Use the Collections class for sorting. Do not create a second list with the names in a different order. Do not modify the ArrayList or its contents except by using the Collections method(s). Your class will be called SortNames.

Like this? Is this clearer than "Do not store modified names in the ArrayList."?
[ May 03, 2002: Message edited by: Marilyn deQueiroz ]
 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Collections class sounds better than Collections method(s).
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Load an ArrayList with Strings from a text file of names. Show the names sorted in order of first name and then by last name. Use com.javaranch.common.TextFileIn to read the names. Use the Collections class for sorting. Do not create a second list with the names in a different order. Do not modify the ArrayList or its contents except by using the Collections class. Your class will be called SortNames.


Yes, I like this better.
 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, that looks like the one
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice and clear.
 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice improvement!
 
Trailboss
Posts: 23773
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds good to me. M, make it so! Engage! Warp 9!
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the clarification! Not bad timing considering it's the next assignment on my list.
Wow, Paul Wheaton droppin' a note in the good ol' Java College! (This is almost like meeting Obi-Wan Kenobi)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic