- Java code
public class TestOperator { public static void main(String[] args) { char s[]={'h','e','l','l','o'}; int i=4; int iArray[]; iArray=new int[4]; for(;i>0;i--) { iArray[i]=s[i]>>4; System.out.println(iArray[i]); } }}
报错:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at TestOperator.main(TestOperator.java:12)
求解释。
------解决方案--------------------------------------------------------
- Java code
public class TestOperator { public static void main(String[] args) { char s[]={'h','e','l','l','o'}; int i=4; int iArray[]; iArray=new int[[del]5[/del]]; for(;i>0;i--) { iArray[i]=s[i]>>4; System.out.println(iArray[i]); } }}