+ 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.

18th Apr 2015, 9:56 PM
Raleigh Thomas
Raleigh Thomas - avatar
10 Respostas
+ 3
Because array starts with zero
23rd Apr 2015, 10:49 AM
Danijel Turić
Danijel Turić - avatar
+ 1
because the numbering of array starts with 0... it is an indexed type
15th Dec 2015, 6:43 PM
Neha Jella
0
Array starts with 0=A 1=B 2=C
20th Jul 2015, 12:04 AM
Mark Washington
Mark Washington - avatar
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.
15th Feb 2016, 2:18 AM
Chaman Sharma
Chaman Sharma - avatar
0
arraylist is start from the index 0
22nd Jun 2016, 4:06 PM
gandhiyash
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
26th Jun 2016, 2:59 PM
John Call
John Call - avatar
0
142px
28th Jun 2016, 5:59 AM
Ira Maarit Laamanen
Ira Maarit Laamanen - avatar
0
nice question !!!
4th Jul 2016, 3:15 PM
Î±Ń•ĐœÏ‰ÎčĐž ĐŒÏƒĐœÎ±Đž
Î±Ń•ĐœÏ‰ÎčĐž ĐŒÏƒĐœÎ±Đž - avatar
0
B
21st Jul 2016, 5:56 PM
Sudhanshu Srinivas Sadul
Sudhanshu Srinivas Sadul - avatar
0
b
29th Nov 2016, 10:51 PM
Tanveer Aslam
Tanveer Aslam - avatar