为什么下面的代码抛出索引越界异常?

3yhwsihp  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(143)

**已关闭。**此问题需要调试详细信息。它目前不接受答案。
**想要改进此问题?**更新问题,使其位于堆栈溢出主题上。

五小时前关门了。
改进这个问题

int[] solution = new int[n];
int start=0;
int end=n-1;
int k=0;

while(start<=end){
    solution[k++]=arr[end--];
    solution[k++]=arr[start++];
}

for(int x=0;x<solution.length;x++){
    arr[x]=solution[x];
}

上面的代码在编译时抛出arrayindexoutofbounds异常y?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题