• 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

K&B errata. Is this a new one not in the list?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Referring to chapter 3 self-test, question 7 (in my version it is page 269 for the question/answer on the class 'Zippy').

The answer given is A - all are legal

When I compile it I get a compile error stating the variable may not have been initialised (the shortened code snippet is below):
String[] x;
Object[] d=x;


However, I am running 1.6 and not 1.5 so don't know if this changes things - compiling with -source still fails. I hope not, otherwise I might have the wrong idea in my head for lots of things!

Thanks.
 
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi neil, are you sure that you code is ok?

on the book the code is:



and for me, that compile fine.

and the version of my javac is 1.6.0_02

maybe you have the arrays inside a method, like this:



...and when you try to compile, the output is:


[ January 24, 2008: Message edited by: Milton Ochoa ]
 
neil walker
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ah, sorry, i'm so used to pasting the code inside the same file that I didn't even notice it was inside main and not the class! I'm never going to pass this exam when I can't spot the obvious
[ January 25, 2008: Message edited by: neil walker ]
reply
    Bookmark Topic Watch Topic
  • New Topic