• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

illegal array reference assignments...

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in K&B's book on pg 225, 3rd chapter, fig 3.6.... the illegal reference assignments whcih are given below... the last one... that is...
myCats[0][1]= moreCats;
the explaination given for this is "cant assign an array object to a nonarray refernce"... but in the code moreCats is a reference variable, not an array object... so should it be moreCats[0]....

thanks..
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
myCats is a 2-D array object of Cat (i.e., Cat[][]).
moreCats is a 1-D array object of Cat (i.e., Cat[]).

In this case (myCats[0][1]= moreCats ) ,they are trying to assign a Cat[] (Right hand side value i.e moreCats) to a Cat object (left hand side value i.e., myCats[0][1]).

Would have been valid if the assignment is

myCats[0][1]= moreCats[0];
[ December 22, 2007: Message edited by: Thirugnanam Saravanan ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic