1.
Q8: The value of
beta.get(0)
is .
add()
get(<expression>)
method call (remember evaluating expressions subgoals)
get
represents the index in the ArrayList. The size of the ArrayList is the number of elements contained. If the ArrayList is initially empty, the size is 0.
arrayListName.size() - 1
, inclusive; otherwise IndexOutOfBoundsException
occurs
arrayListName.get(index)
returns the value stored at that index
set(<expression>, value)
method call which will be the index for the element to be updated
ArrayList<Integer> beta;
beta
after the execution of these statements.
int size = 4;
beta = new ArrayList<Integer>();
beta.add(50);
for (int i = 1; i < size; i++)
beta.add(beta.get(i-1) - 2);
beta.get(0)
is .
beta.get(1)
is .
beta.get(2)
is .
beta.get(3)
is .