Possible Duplicate:
How to convert object array to string array in Java
I am receiving an Object and casting it into a String array like this:
Object values[] = (Object[])request.getSession().getAttribute("userList");
String[] tmp = new String[values.length];
for(int i = 0; i < tmp.length; ++i) {
tmp[i] = (String) values[i];
out.println(tmp[i]);
}
Is there any better and cleaner way to do this?
Why not directly casting?
String values[] = (String[])request.getSession().getAttribute("userList");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With