0

why does it print out C

public class Program { public static void main(String[] args) { String[ ] myNames = { "A", "B", "C", "D"}; System.out.println(myNames[2]); } }

26th Aug 2016, 5:45 PM
Aquarius
Aquarius - avatar
3 Answers
+ 5
couse the index starts from zero not one myNames [0] 》A myNames [1] 》B myNames [2] 》C
26th Aug 2016, 6:29 PM
Tiger
Tiger - avatar
0
oh ok thank you
26th Aug 2016, 8:10 PM
Aquarius
Aquarius - avatar
0
it myNames[2]=C
2nd Sep 2016, 3:23 PM
Abhijay Bisht
Abhijay Bisht - avatar