ArrayList Size Method
Which of the following code snippets correctly fills in the missing code to store the size of the ArrayList in a variable?
import java.util.ArrayList;
public class Test {
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<String>();
list.add("Alpha");
list.add("Beta");
// Missing Code: print the size of list.
System.out.println("Size: " + size);
}
}
A
int size = list.length;
B
int size = list.getSize();
C
int size = list.size();
D
int size = list.size;
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | geethasailaja | 2 | 2 | 0m 35s | 165 |
| #2 | kaisuki | 1 | 2 | 0m 00s | 90 |
| #3 | singhris000 | 1 | 1 | 0m 12s | 88 |
| #4 | y.seong2027 | 1 | 2 | 34m 02s | -1,952 |
APFIVE