SJSU/Udacity CS046

Lesson 7.2 - Array Lists and Arrays

  1. Arrays
  2. Array Elements
  3. Quiz: First Five Primes
  4. Quiz: Modifying the Array
  5. Quiz: Put 10 in the First and Last Spaces
  6. Quiz: Array of Strings
  7. Quiz: Enhanced For Loop
  8. Arrays or ArrayLists
  9. Partially Filled Arrays
  10. Homework Scores
  11. Homework Scores Continued
  12. Quiz: Read Scores
  13. Quiz: Sum Scores
  14. Quiz: Average Scores
  15. Inserting and Removing Arrays
  16. Quiz: Inserting and Removing Arrays Continued
  17. Quiz: Removing Lowest Score
  18. Quiz: Find Lowest Scoring Position
  19. Can We Streamline More

Quiz: Inserting and Removing Arrays Continued

In the preceding video clip, Cay didn't actually go into detail how removal works. It works just like insertion, except that the elements are moved towards the beginning of the array. First you overwrite the element to be removed. You keep going until all values are moved:

for (int i = pos; i < size - 1; i++)
{
   values[i] = values[i + 1];
}
size--;
How many elements were visited? 10

Problem on this page?

Your name:

Your email address:

Problem description:

To protect against spam robots, please answer this simple math problem:
× =