求助,怎么显示Unknown Source
代码如下:import java.util.*;
final class element{
int num;
public element()
{
num=0;
}
public element(int num){
this.num=num;}
}
public class java_th extends Thread {
Vector vt=new Vector();
String str;
element num;
int position;
public java_th( int position,element num){
this.num=num;
this.position=position;
}
public void run(){
vt.add(position, num);
this.str=vt.toString();
System.out.println(str);
}
static public void main(String args[]){
Thread t1=new Thread(new java_th(3,new element(3)));
t1.start();
Thread t2=new Thread(new java_th(6,new element(6)));
t2.start();
}
}
结果显示:
Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: 3 > 0
at java.util.Vector.insertElementAt(Unknown Source)
at java.util.Vector.add(Unknown Source)
at java_th.run(java_th.java:21)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBoundsException: 6 > 0
at java.util.Vector.insertElementAt(Unknown Source)
at java.util.Vector.add(Unknown Source)
at java_th.run(java_th.java:21)
at java.lang.Thread.run(Unknown Source)
请问这是什么原因 ?
搜索更多相关主题的帖子:
Source Unknown
----------------解决方案--------------------------------------------------------
程序在运行时产生数组越界!
[此贴子已经被作者于2007-4-23 23:13:23编辑过]
----------------解决方案--------------------------------------------------------