求助,java.lang.ArrayIndexOutOfBoundsException: 1

来源:百度知道 编辑:UC知道 时间:2024/06/04 09:15:20
这是我一个没写完的程序,但遇到了这么个错误,非常郁闷,望高手不吝赐教
Exception in thread "Thread-2" java.lang.ArrayIndexOutOfBoundsException: 2
at MainFrame.initial(MainFrame.java:145)
at MainFrame$2.run(MainFrame.java:202)
at java.lang.Thread.run(Unknown Source)
public void initial() throws IOException{
NetworkInterface[] devices=JpcapCaptor.getDeviceList();
int index=1;
JpcapCaptor captor=JpcapCaptor.openDevice(devices[index],65535, true,20);
PacketReceiver handler;
handler=new PacketReceiver(){
public void receivePacket(Packet packet) {
//System.out.println(packet);

dealPacket(packet);
}
};

我只能看出这个异常是有关数组下标越界的.其他的要看你的程序了.

数组devices里应该只有一个元素,你把index的值定义为 0 应该就可以了.

java.lang.ArrayIndexOutOfBoundsException
数组下标越界
把代码贴上来啊。。。