本帖最后由 大西洋 于 2015-4-26 22:41 编辑
程序运行后会在下面这段代码的第四行报错:
错误提示:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 数组越界了- public int compare(InetAddress i1,InetAddress i2){
- String[] str1 = i1.toString().split(".");
- String[] str2 = i2.toString().split(".");
- int num = new Integer(str1[1]).compareTo(new Integer(str2[0]));
- if(num==0){
- num = new Integer(str1[1]).compareTo(new Integer(str2[1]));
- if(num==0){
- num = new Integer(str1[2]).compareTo(new Integer(str2[2]));
- if(num==0){
- num = new Integer(str1[3]).compareTo(new Integer(str2[3]));
- }
- }
- }
-
复制代码
请问这是什么原因??谢谢
|
|