我在变量中有一个String值,例如ID
XML Like
<DocumentElement><Contact ID="1" Name="Test1" 1/><Contact ID="2" Name="TEST" /></DocumentElement>
我在_s2
中得到了我的身份证明我想在像StringArr
这样的字符串数组中添加所有id我已完成
Count=0;
EmailArr=new String[Count];
String _s2=event.getAttribute("ID").getValue();
if(_s2=="" || _s2==null){
_s2="N/A";
}
if(_s2!=null){
EmailArr[Count]=_s2;
Count=Count++;
}
我得到了例外java.lang.ArrayIndexOutOfBoundsException
答案 0 :(得分:0)
您需要使用Xml值创建一个数组: -
int count=XMlData.getPropertyCount();// Get the XML Data count/ some thing related to get Count of XMl Details
EmailArr=new String[Count]; // create Array EmailArr with that Count
答案 1 :(得分:0)
您应该为数组提供一些初始大小:
EmailArr=new String[Count];//where count is number of records