AlistairMonkeyFinger
Programmer
Is there an easy way to convert (cast) a Object array to a String array ?
thanks Alistair![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)
thanks Alistair
![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
for(int i=0;i<strArray.length;i++){
strArray[i] = objArray[i].toString();
System.out.println(""+strArray[i]);
}
public class Test {
private static String[] s = { "1", "2", "3" };
public static Object method1() {
return s;
}
public static Object[] method2() {
return s;
}
public static void main(String[] args) {
String[] s2;
s2 = (String[]) method1();
for(int i = 0; i < s2.length; i++)
System.out.println(i+": "+s2[i]);
s2 = (String[]) method2();
for(int i = 0; i < s2.length; i++)
System.out.println(i+": "+s2[i]);
}
}
private static Object[] s = new String[] { "1", "2", "3" };