本文主要是介绍ArrayIndexOutOfBoundsException,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 下标超出范围了, p288
at e16_01.Example_01.<init>(Example_01.java:18)
at e16_01.Main_01.main(Main_01.java:8)
package e16_01;public class Example_01 {
String s;
int i,i2,i3;
private Example_01(){
}
protected Example_01(String s,int i){this.s=s;this.i=i;}
public Example_01(String... strings)throws NumberFormatException{if(0<strings.length)i=Integer.valueOf(strings[0]);if(1<strings.length)i2=Integer.valueOf(strings[1]);if(2<strings.length)i3=Integer.valueOf(strings[3]); //strings[3]应该改成2才对}
public void print(){System.out.println("s="+s);System.out.println("i="+i);System.out.println("i2="+i2);System.out.println("i3="+i3);
}
}
这篇关于ArrayIndexOutOfBoundsException的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!