System.arraycopy getting java.lang.ArrayIndexOutOfBoundsException

前端 未结 4 1669
再見小時候
再見小時候 2021-01-13 08:12

System.arraycopy getting ava.lang.ArrayIndexOutOfBoundsException.. I am trying to copy data from one array to the next. but I am getting a exception

privat         


        
4条回答
  •  星月不相逢
    2021-01-13 08:45

    Because the length of array is 1.

    The declaration array[] = { "NO DATA YET" }; creates an array of length 1 with one item in it.

    Instead declare destination array as:

    private String array[] = new String[8];
    

提交回复
热议问题