Code Explained with comment
1 class Dims {
2public static void main(
String[] args) {
3 int[][] a={ {1,2}, {3,4} }; // Creating two dimensional Array with
//a[0] = {1,2} and a[1] = {3,4}
4int[] b= (int[]) a[1]; // assigning a[1] to b
5Object o1=a; // Remember a is also an object so
// upcasting to Object
6int[][] a2=(int[][])o1; // assigning a to a2 with downcasting
7int[] b2=(int[]) o1; // Run Time exception as ol can only be
//type casted to 2- d array
8System.out.println(b[1]);
}
}
Thanks and Regards,
Gaurav Joshi