Topic: 运行后的提示~看不懂(ArrayIndexOutOfBoundsException)

  Print this page

1.运行后的提示~看不懂(ArrayIndexOutOfBoundsException) Copy to clipboard
Posted by: aiff
Posted on: 2004-10-11 09:08

public class snake3 {

public static void main (String args[])
{
int s[]={5,10,15,20,25};
int k[]={6,13,15,2,43};
for (int i=0;i<s.length;i++)
{
if(s[i]>k[i])
System.out.println(s[i]+">"+k[i]);
if(s[i]<k[i])
System.out.println(s[i]+"<"+k[i]);
if(s[i]==k[i])
System.out.println(s[i]+"="+k[i]);
}
}

}


JAVAC提示
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at snake3.main(snake3.java:7)

2.Re:运行后的提示~看不懂 [Re: aiff] Copy to clipboard
Posted by: littledeer1974
Posted on: 2004-10-11 09:28

数组边界溢出?应该是吧

3.Re:运行后的提示~看不懂(ArrayIndexOutOfBoundsException) [Re: aiff] Copy to clipboard
Posted by: why
Posted on: 2004-10-11 10:23

请尽量用准确的文字描述作为标题

Your code looks okay to me.
It should be fine as long as the length of s and that of k are the same.

4.Re:运行后的提示~看不懂(ArrayIndexOutOfBoundsException) [Re: aiff] Copy to clipboard
Posted by: eric_dasini
Posted on: 2004-10-11 10:40

你的程序好像没什么错误啊
我运行了!

你的错误提示是: 数组越界

5.Re:运行后的提示~看不懂(ArrayIndexOutOfBoundsException) [Re: aiff] Copy to clipboard
Posted by: Hanf
Posted on: 2004-10-11 18:03

JAVAC提示
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at snake3.main(snake3.java:7)

----------------
1、JAVAC提示?
2、第7行代码?
3、下标从0计,此代码最大下标4,5越界

6.Re:运行后的提示~看不懂(ArrayIndexOutOfBoundsException) [Re: aiff] Copy to clipboard
Posted by: cjyzpcl
Posted on: 2004-10-11 20:25

程序没有错误!
而且javac不会产生异常错误输出的!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923