The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Error on K&B book (Java 6) page 579 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Error on K&B book (Java 6) page 579" Watch "Error on K&B book (Java 6) page 579" New topic

Error on K&B book (Java 6) page 579

Bhaarat Sharma
Ranch Hand

Joined: Jun 04, 2007
Posts: 96
I believe there is an error on page 579 in the toArray() section

Now let's take a look at the toArray() method. There's nothing too fancy going
on with the toArray() method; it comes in two flavors: one that returns a new
Object array, and one that uses the array you send it as the destination array:

the line

will throw an Incompatible types error because required is Integer[] and found is Object[]

Have other people noticed this as well or am I doing something wrong?

Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1167
Hi, it complies and runs. It seems to be a fine widening conversion of iL.


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Bhaarat Sharma
Ranch Hand

Joined: Jun 04, 2007
Posts: 96
My fault.

I see my mistake. I guess its time to hit the bed for me.

shivdhwaj pandey
Ranch Hand

Joined: Nov 12, 2011
Posts: 63

go and take proper sleep dude

with regards,
Shivdhway Pandey
Consider Paul's rocket mass heater.
subject: Error on K&B book (Java 6) page 579
Similar Threads
Unable to understand toArray()
Using for..each loop on Object[]
Discussing errata for K&B, SCJP 6
Why can't we use the IS-A test for the enhanced for-loop?