• 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

two dimensional array

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'm giving the scjp1.6 exam end of this month. I'm preparing that K & B book. I have some doubts on this book. In the Assignments chapter I dont understand the legal and illegal array assignments of two dimensional array according to the figure 3-6(which is in page:235).
If anyone knows please explain me.And want to know how many objects are there?

Waiting for your replay
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

You've posted this question in the "Sun Certification Results" forum. That forum is meant for announcing your result with regard to a Sun certification exam - for example, if you passed or failed the exam. Your question doesn't belong in this forum. I'll move it to a more appropriate forum for you.
 
Ranch Hand
Posts: 537
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forget about that diagram. Keep it simple.

int[] i1 = new int[5] <= single dimensional array
int[][] i2 = new int[3][3] <= double dimensional array
int i3 = 3;

i1 = i3 <= is not possible because i1 expects an array
i2 = i1 <= is not possible beacause i2 expects a 2 dimensional array.
i2[0] = i1 <= possible because i2[0] needs a array object.

in the diagram.Cat [][] mycats cannot be assigned to mycats[0](A) or mycats[0][0](B) because Cat[][] mycats requires a 2 dimensional array and you are passing a single dimensional array and a object respectively.Also in (D) mycats[0][0] needs a value like a primitive or a object(not array object) so it cannot be assigned to a 1 dimensional array object. Well the diagram is simple enough
 
reply
    Bookmark Topic Watch Topic
  • New Topic