Limited access

Upgrade to access all content for this subject

The following method counts the number of times a value (represented by key) appears as an element in an ArrayList named nums.

public static int search(ArrayList<Integer> nums, int key)
{
    int j = 0;
    for ( /*missing code*/ )
        if (key == x)
            j++;
    return j;
}

Which of the following should replace /*missing code*/?

A
int x : nums
B
int x : nums.get(i)
C
int x = 0; x < nums.length; x++
D
int x = 0; x
E
int x = nums.size() - 1; x >= 0; x--
Select an assignment template