epifanio67
asked on
Java: why can I not add values to my Object[ ]?
Hello Experts,
Why can I not add values to my Obj [ ] ?
In advance, thank you for your help...
Regards,
Why can I not add values to my Obj [ ] ?
public static void main(String args[]) {
Pattern p = Pattern.compile("Sip\\w*");
String file = "message SipRoute test in SipUser " + "\n"
+ "receipt SipCall at time SipUpdate " + "\n"
+ "message SipReg during SipDiv " + "\n";
ArrayList<String> list = new ArrayList<String>();
Object obj[] = null;
Matcher matcher = p.matcher(file);
while(matcher.find() == true){
list.add(matcher.group());
obj = new Object[]{matcher.group()};
}
//prints arraylist ok
for (int x = 0; x < list.size(); x++) {
System.out.println("myArray: " + list.get(x));
}
//fails to add to Obj array - why?
for (int x = 0; x < obj.length; x++) {
System.out.println("obj: " + obj[x]);
}
}
In advance, thank you for your help...
Regards,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)
ASKER
Thx for your help...
Regards,