File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Question on deepToString() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question on deepToString()" Watch "Question on deepToString()" New topic

Question on deepToString()

Thomas Kennedy
Ranch Hand

Joined: Jan 20, 2008
Posts: 137
On the Sun self-assessment for 310-055 there is a question as follows:

int[] a = {7,9,8};
int[][] aa = {{1,2,3},{6,5,4}};
int[][][] aaa = {{{1,2},{3,4}},{{5,6},{7,8}}};

which will compile?

a. System.out.println(Arrays.deepToString(a));
b. System.out.println(Arrays.deepToString(aa));
c. System.out.println(Arrays.deepToString(aaa));

Now the signature for deepToString() is

So I can see why b & c would compile: they are arrays of arrays, that is, arrays of objects. Is that the reason (a) will not compile, that it is an array of primitives? Am I missing anything here?

I see here that Bert says this is not on the exam but I'm not taking any chances.

Costs matter. Justice lies in processes not outcomes. Crime is caused by criminals.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Yep, an int[] is not an Object[]. That's all there is to it.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Question on deepToString()
It's not a secret anymore!