public class HelloWorld{
public static void main(String []args){
System.out.println("Hello World");
String s = new String("abc");
int [] a = {1,2,3,4};
System.out.println(s);
System.out.println(a[1]);
Object o1 = s;
Object o2 = a;
System.out.println(o1);
System.out.println(o2[2]);
}
}
I am geeting the following error after compiling and executing the aforementioned code on the website http://www.compileonline.com/compile_java_online.php :
Compiling the source code....
$javac HelloWorld.java 2>&1
HelloWorld.java:12: error: array required, but Object found
System.out.println(o2[2]);
^
1 error
How do I print each element of the array saved in the object o2?