• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on deepToString()

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 https://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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, an int[] is not an Object[]. That's all there is to it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic