Page 713 - AP Computer Science A, 7th edition
P. 713

38. (A) The size variable stores the number of unused tiles, which are in the tiles list from position 0 to position size. A random int is selected in this range, giving the index of the Tile that will be swapped to the end of the unused part of the tiles list. Note that the length of the tiles ArrayList stays constant. Each execution of getNewTile decreases the “unused tiles”
part of the list and increases the “already used” part at the end of the list. In this way, both used and unused tiles are stored.

































































































   711   712   713   714   715