English subtitles

← Talk To - Intro to Java Programming

Get Embed Code
5 Languages

Showing Revision 4 created 05/25/2016 by Udacity Robot.

  1. I'm going to use the find method again. I need to find the
  2. index of the person I want to move. In this example it would
  3. be four. Then I need to remove them from that spot, so
  4. that I won't have two copies of that person in the list. And
  5. then the induces would change accordingly. Then once I've removed them, then
  6. I want to add them at the front. I'm going to use add
  7. instead of set, because I don't wipe to away the zeroth one,
  8. I just want to move everybody down. So now this will be zero,
  9. this will be one, two, three, four, five. In BlueJ that would look like,
  10. get the Old Index, by finding the Person. And then if that Person is already
  11. a friend we remove them from their old position and insert them into the
  12. zeroth spot. If they're not already a friend, then we don't have to do anything.