我正在为我的课程开发一个while循环示例。该循环将简单地通过并使用人名和他们的号码创建电话列表。这是我到目前为止,但是当我运行它会显示第一个字符串,然后出现超出界限的异常。我是一般的Java和编程新手,只是寻求一些建议,并帮助我在哪里可以做得更好。谢谢你的时间。while循环“超出范围例外”
public class WhileLoop {
public static void main(String[] args){
String friends [][] = new String [10][2];
friends [0][0] = "Angel";
friends [0][1] = "555-555-5555";
friends [1][0] = "Brandon";
friends [1][1] = "444-444-4444";
friends [2][0] = "Christina";
friends [2][1] = "111-111-1111";
friends [3][0] = "Donte";
friends [3][1] = "222-222-2222";
friends [4][0] = "Ashley";
friends [4][1] = "333-333-3333";
friends [5][0] = "Tommy";
friends [5][1] = "777-777-7777";
int totalElements = friends.length;
int i=0;
for (i=0; i<totalElements; i++){
System.out.println("Phone Listing for: " + friends[i][i]);
}
}
}