我查看了其他问题,但不完全是我在这里面临的问题,这是我拥有的当前代码
public class Qn3 {
public static void displayHighestMark(String[] names,int[] marks, int count)
{
int mark = 0;
int currentArrayPosition;
for(int i=0;i <= names.length;i++)
{
if(mark <= marks[i])
mark = marks[i];
currentArrayPosition = i;
}
System.out.println(name[i]+" with marks "+mark);
}
public static void main(String[] args)
{
String[] names = new String[]{"jack","hello","A","b","c","d"};// = new String[];
int[] marks = new int[]{1,2,3,8,5,6};
displayHighestMark(names,marks, 45);
}
}
所以基本上我试图在标记数组中找到最高分。但我越来越期待 ArrayIndexOutOfBoundsException