Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion regarding mitidimentional array please help

 
shashank pratap
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Dims{
public static void main(String[] args){
int [][] a={{1,2},{3,4}};
int[] b=(int[])a[1];
Object o1=a;
int [][] a2=(int[][])o1;
System.out.println(b[1]);
}}

the answer to this q is given is " an exception is thrown at runtime" page number 278 Kathy & Bert (310-065)
but when i compile this program on java5 compiler this showing me the output
please help m,e
 
M K Rayapudi
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the text book, the following line of code is also there

int[] b2 = (int[]) o1;

check once again the text book
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic