ArrayIndexOutOfBoundsException来找我

时间:2019-03-16 16:10:24

标签: java arrays cycle

我的代码:

  String key = "82937549823749832759837495864385734";
        String[] keys = new String[10];

        int k = 0;
        for (int i = 0; i<key.length(); i=+10){
            String sub = key.substring(i, i+10);
            keys[k] = sub;//23-th stroke
            k++;
        }
System.out.print(keys[0]);

我得到异常Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10 at HelloWorld.main(HelloWorld.java:23)   我想将字符串以10个字符分隔

0 个答案:

没有答案