ArrayIndexOutOfBoundsException意

ArrayIndexOutOfBoundsException意

本文介绍了是什么java.lang.ArrayIndexOutOfBoundsException意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Java,今天我开始对数组工作,我迷路了。我想放一些数值数组,但我得到的错误 java.lang.ArrayIndexOutOfBoundsException

这是我迄今所做的。

  INT N = 6;
      INT [] A = INT新[1];      对于(i = 0; I< N;我++){
          A [i] = keyboard.nextInt();
      }


解决方案

java.lang.ArrayIndexOutOfBoundsException意味着你试图访问不存在的数组索引。

问题是,你的数组大小one.However的,你是通过循环六次去。您可以从N等于一体,或增加您的数组的大小。

I am new to java and today I started to work on arrays and I'm lost. I am trying to put some values in an array but I'm getting the error java.lang.ArrayIndexOutOfBoundsException.

Here is what I have done so far.

      int n=6;
      int[]A= new int [1];

      for(i=0;i<n;i++){
          A[i]=keyboard.nextInt();
      }
解决方案

java.lang.ArrayIndexOutOfBoundsException means you are trying to access a array index that doesn't exist.

The problem is that your array is of size one.However, you are going through that loop six times. You can either make n equal to one, or increase the size of your array.

这篇关于是什么java.lang.ArrayIndexOutOfBoundsException意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 15:55