ArrayIndexOutOfBoundsException异常 [英] ArrayIndexOutOfBoundsException

查看:75
本文介绍了ArrayIndexOutOfBoundsException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){


String Temp = jComboBox1.getSelectedItem()。toString ();


testcomm.TestForm。 WriteParamToPic (" c" + Temp);


}


public static void WriteParamToPic(String ParamIn)

{

char [] WriteParam = new char [4];

byte [] FinalWriteParam = new byte [4];

WriteParam = ParamIn.toCharArray();

for(int i = 0; i< 4; i ++){

FinalWriteParam [i] =(byte)WriteParam [i];

Comm.PutPointerData(FinalWriteParam,4);

}

}






我拥有:

jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String [] {" 30"," 50"}));
我得到nex err或者:

java.lang.ArrayIndexOutOfBoundsException


我必须为WriteParamToPic配置参数吗?

我已经托盘来更改 WriteParamToPic 中的数组数量,但它会返回其他错误。


谢谢


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

String Temp = jComboBox1.getSelectedItem().toString();

testcomm.TestForm.WriteParamToPic("c"+Temp);

}


public static void WriteParamToPic(String ParamIn)
{
char [] WriteParam = new char[4];
byte [] FinalWriteParam = new byte[4];
WriteParam = ParamIn.toCharArray();
for(int i=0; i<4; i++){
FinalWriteParam[i] = (byte) WriteParam[i];
Comm.PutPointerData(FinalWriteParam,4);
}
}







I have:
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"30", "50" }));
i get nex error:
java.lang.ArrayIndexOutOfBoundsException


Hove must i configure argument for WriteParamToPic?
I have trayed to change number of arrays in WriteParamToPic, but it returns me other errors.

Thank you

推荐答案


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){



String Temp = jComboBox1.getSelectedItem()。toString();


testcomm.TestForm。< u> WriteParamToPic (\" c \" + Temp);


}


public static void WriteParamToPic(String ParamIn)

{

char [] WriteParam = new char [4];

byte [] FinalWriteParam = new byte [4];

WriteParam = ParamIn.toCharArray();

for(int i = 0; I< 4; i ++){

FinalWriteParam [i] =(byte)WriteParam [i];

Comm.PutPointerData( FinalWriteParam,4);

}

}











我有:


jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String [] {\" 30 \",\" 50 \" ;}));

我得到nex错误:


java.lang.ArrayIndexOutOfBoundsException





Hove必须为WriteParamToPic配置参数吗?


我已经托盘改变了< u> WriteParamToPic ,但它会返回其他错误。



谢谢

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {



String Temp = jComboBox1.getSelectedItem().toString();



testcomm.TestForm.WriteParamToPic(\"c\"+Temp);



}



public static void WriteParamToPic(String ParamIn)

{

char [] WriteParam = new char[4];

byte [] FinalWriteParam = new byte[4];

WriteParam = ParamIn.toCharArray();

for(int i=0; i<4; i++){

FinalWriteParam[i] = (byte) WriteParam[i];

Comm.PutPointerData(FinalWriteParam,4);

}

}













I have:

jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {\"30\", \"50\" }));

i get nex error:

java.lang.ArrayIndexOutOfBoundsException





Hove must i configure argument for WriteParamToPic?

I have trayed to change number of arrays in WriteParamToPic, but it returns me other errors.



Thank you



FinalWriteParam [i] =(byte)WriteParam [i];

此时WriteParam比FinalWriteParam长,因为



FinalWriteParam[i] = (byte) WriteParam[i];
At this point WriteParam is longer than FinalWriteParam because

展开 | 选择 | Wrap | 行号


非常感谢。我再也不会收到错误了。


但现在,我会去托盘解释下一个问题。如果我们很好地解决它,我会更接近我最后的教职员工。


我正在向我发送数据(参数) PIC单片机。我已申请调节温度。为了控制和监督它,我需要使用图形界面。所以,从Hyper终端我可以做得很好。

我的PIC一个接一个地理解从键盘发送的字符。


但在我的Java工作中: ..

我的代码对我的有效传输没有准确。我必须多次按下(激活传输)按钮才能获得结果,并且传输的数据不够正确。我会感激所有的建议,因为我认为他们很好地导致我必须解决沟通问题。


现在我想。我已经编程微控制器来激活中断痒时间,它在输入上获得数据(一个字符)。因此,在发送

字符之间包括延迟可以让微控制器有时间来详细说明数据。

是的,我认为这可能是正确的方式。所以,如果我恢复,我必须按字符发送字符并包括痒传输之间的最小延迟。好吗?


在发送代码之前继续:
Thank you wery much.I don''t get error any more.

But now, I?ll gone to tray to explain next problem. And if we well resolve it, I?ll
be much closer to my final faculty work.

I''m sending data (parameters) to the PIC microcontroller. I have made application for regulation of temperature. And to control and supervise it i need to use a graphic interface. So, from Hyper terminal i can do it wery well.
My PIC understands characters sent from keyboard one by one.

But in my Java work:...
my code doesn?t accurate me valid transmission. I have to press (activate transmission) on button several time to get result and much time the transferred data isn?t correct. I''ll appreciate every suggestions because i assume that them well lead me to conclusion have to resolve communication problem.

Now when I think. I have programmed microcontroller to activate interrupt itch time it gets data (one character)on him input. So it could be resolution to include a delay between sending of
characters to give microcontroller time to elaborate data.
Yes , I think this could be wright way. So if I resume I have to send character by character and to include minimum delay between itch transmission.Wright?

To continue before sent code:
展开 | 选择 | Wrap | 行号


现在我有一个具体的问题:

And now i have a concrete problem:

展开 | 选择 | Wrap | 行号


这篇关于ArrayIndexOutOfBoundsException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆