mtdhwgij
发贴: 13
积分: 0
|
于 2006-05-19 22:42
同楼主,我也出现了同一个问题,即使是个简单的hello,world!也出现这种线程错误,现将错误提示输出: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Search.main(Search.java:13) Press any key to continue... 这是源程序:
public class Search { static int linearSearch(int a[],int key) { for (int n=0;n<a.length;n++) if (a[n]==key) return n; return-1; } public static void main(String args[]) { int a[]={25,36,47,32,21,16}; int key=Integer.parseInt(args[0]); int k=linearSearch (a,key); if (k!=-1) System.out.println("Found value in element"+k); else System.out.println("key"+key+"nou found"); } } 使用的是JCreator软件同楼主
|