+ 1
What is the output of this code?
ArrayList list = new ArrayList(); list.add("A"); list.add("B"); list.add("C"); System.out.println(list.get(1)); Why is it B? thanks in advance.
10 Answers
+ 3
Because array starts with zero
+ 1
because the numbering of array starts with 0... it is an indexed type
0
Array starts with 0=A 1=B 2=C
0
Because list works in the similar way as array do so it starts indexing with zero that's why according to this logic B is at 1th position so the answer is B.
0
arraylist is start from the index 0
0
unlike counting natural numbers ie:1,2,2,3,etc an array and lists start with zero so the natural progression would be 0,1,2,3. given that information: 'a'= 0, 'b' = 1, and 'c'= 3, therefore the answer is b
0
142px
0
nice question !!!
0
B
0
b