CSE 142 Lecture Notes - Lecture 30: Infinite Loop

75 views5 pages
Verified Note

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents