| Author |
Dan's Question:clone()
|
tonghua li
Greenhorn
Joined: Jun 07, 2003
Posts: 8
|
|
Hello everyone,I often come to this forum to learn Java,but It is the first time post new topic. Could someone tell me why the output is 1,1,2? ------------------------------------------------------------------------ class Amber { public static void main(String[] args) { int[][] a = {{1,2},{0,1,2},{-1,0,2}}; Object[] obj = (Object[])a.clone(); for(int i = 0; i < obj.length; i++) { int[] ia = (int[])obj[i]; System.out.println(ia[i]+","); } } }
|
※Study hard and make progress every day※
◎Java:SCJP,SCWCD,SCBCD,SCDJWS,SCEA
◎Solaris:SCSA
◎Oracle:OCA,OCP
◎PMI:PMP
|
 |
Dan Chisholm
Ranch Hand
Joined: Jul 02, 2002
Posts: 1865
|
|
Welcome to the JavaRanch and thank you for using my exam. The program prints the values contained in ia[0][0], ia[1][1] and ia[2][2].
|
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
|
 |
 |
|
|
subject: Dan's Question:clone()
|
|
|