File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on deepToString()

 
Thomas Kennedy
Ranch Hand
Posts: 137
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the Sun self-assessment for 310-055 there is a question as follows:

Given:
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 http://www.coderanch.com/t/268592/java-programmer-SCJP/certification/todeepArray that Bert says this is not on the exam but I'm not taking any chances.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, an int[] is not an Object[]. That's all there is to it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic