i am not allowed to use a sort method
William Brogden wrote:
i am not allowed to use a sort method
How about using a collection that automatically sorts, is that "allowed?"
Campbell Ritchie wrote: You may need to find out about ordering objects. Fortunately the Java Tutorials has a section which covers just that.
Mansukhdeep Thind wrote:Wouldn't Daniel's methodology suffice here Jeff?
Jeff Verdegan wrote:
Mansukhdeep Thind wrote:Wouldn't Daniel's methodology suffice here Jeff?
I don't know who Daniel is, and I don't know what specific difficulty the OP is having in meeting his requirements, so I can't answer that, nor do I know if it's even relevant.
~ Mansukh
Alan Anderson wrote:Jeff I need to shift values in elements...Say i have student[0] = "Fred", if i add Anthony to the array, since Anthony comes before Fred, i want Anthony to replace Fred at student[0] and then move Fred to student[1]...and all these while am adding new student record.
Campbell Ritchie wouldn't the arrayCopy require me creating another array? that is a destination array?
~ Mansukh
Mansukhdeep Thind wrote:
Alan Anderson wrote:Jeff I need to shift values in elements...Say i have student[0] = "Fred", if i add Anthony to the array, since Anthony comes before Fred, i want Anthony to replace Fred at student[0] and then move Fred to student[1]...and all these while am adding new student record.
Campbell Ritchie wouldn't the arrayCopy require me creating another array? that is a destination array?
As I see it, you need to check the name to be added with the existing names in the array and accordingly add the new entry at the respective index position. Am I correct? Is this the exact use case Alan?
Alan Anderson wrote:Jeff I need to shift values in elements...Say i have student[0] = "Fred", if i add Anthony to the array, since Anthony comes before Fred, i want Anthony to replace Fred at student[0] and then move Fred to student[1]...and all these while am adding new student record.
Campbell Ritchie wouldn't the arrayCopy require me creating another array? that is a destination array?
Alan Anderson wrote:The answer to all your questions is yes.i don't know where to start.
Do you not know how to determine if Anthony belongs before Fred?
Alan Anderson wrote:Campbell Ritchie wouldn't the arrayCopy require me creating another array? that is a destination array?
That is what I was going to say. I shall say something else:Stuart A. Burkett wrote:] . . . two references can refer to the same object.
~ Mansukh
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
|