Why? (ง •_•)ง? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Why? (ง •_•)ง?

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

22nd Mar 2017, 2:57 PM
Michael Wu
Michael Wu - avatar
3 Answers
+ 20
The computer doesn't say... Hey, this is the first number, so its index is 1... The computer starts the index from 0... Because C is the third element, its index is 2... ;)
22nd Mar 2017, 3:11 PM
Gami
Gami - avatar
+ 15
my names[0] is "A" my names[1] is "B" my names[2] is "C" my names[3] is "D"
22nd Mar 2017, 2:59 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
0
the ans is c
24th Mar 2017, 2:08 PM
cutte