CSE 142 Lecture Notes - Lecture 30: Infinite Loop
CSE 142 verified notes
30/30View all
Document Summary
7 // string s = arr[i]; ==> string s = list. get(i); 8 // arr[i] = s; ==> list. set(i, s); 11 // list. add(s) - adds a new element to the end of the list. 12 // list. add(i, s) - adds a new element at index i, shifting later elements "right" 13 // list. remove(i) - removes and returns the element at index i, shifting later elements "left" 14 // list. clear() - removes all elements from the list. 55 // modifies the given arraylist by moving the longest string. 56 // in the list to the front (index 0) position. 58 // arraylist words - the list to modify. 62 for (int i = 1; i < words. size(); i++) { 74 // modifies the given arraylist to include two copies of each value. 78 // arraylist numbers - the list to modify. 81 // would cause an infinite loop, since we are adding an element to the.