wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's Question:clone() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic

Dan's Question:clone()

tonghua li

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];

※Study hard and make progress every day※
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>
Don't get me started about those stupid light bulbs.
subject: Dan's Question:clone()
It's not a secret anymore!