• 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

SCJP6 book page 298 errata

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I couldn't find an errata for SCJP 6, so I don't know if this was previously addressed.

On page 298 of the SCJP 6 book Table 4-1
5th row - throws a compile time error , does not print false

but the table says the result is false.

Foo[] fa = new Foo[3];
//Following throws compiler error, wont print false
System.out.println(fa instanceof Foo);
System.out.println(fa instanceof Bar);
System.out.println(fa instanceof Face);
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rashmi Jaik:


On page 298 of the SCJP 6 book Table 4-1
5th row - throws a compile time error , does not print false



Neither you provided the code snippet nor URL and I don't have a book to refer, So provide the code !!
 
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rashmi you are correct here, this should be an errata.

Even foo[1] will only return true when
foo[1]=new Foo(); means foo[1] is assigned Foo object.

here is code Sagar:
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I got it now ,
This lines throws the errors :



foo is an object on Foo[], an array object.
 
Rashmi Jaik
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:

Originally posted by Rashmi Jaik:


On page 298 of the SCJP 6 book Table 4-1
5th row - throws a compile time error , does not print false



Neither you provided the code snippet nor URL and I don't have a book to refer, So provide the code !!



This post is only for those who have the book
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rashmi Jaik wrote:

Sagar Rohankar wrote:

Originally posted by Rashmi Jaik:


On page 298 of the SCJP 6 book Table 4-1
5th row - throws a compile time error , does not print false



Neither you provided the code snippet nor URL and I don't have a book to refer, So provide the code !!



This post is only for those who have the book



Oops, Sorry then, sorry for wasting my time and mind..

And thanks Punit for sharing a code for me...
 
Rashmi Jaik
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:

Neither you provided the code snippet nor URL and I don't have a book to refer, So provide the code !!



I thought it was obvious that this post was made only for those who have the book.

I should have made it more obvious. No regrets.
 
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EDITED
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rashmi Jaik wrote:

Sagar Rohankar wrote:

Neither you provided the code snippet nor URL and I don't have a book to refer, So provide the code !!



I thought it was obvious that this post was made only for those who have the book.


Ok, fine.
Those who got that book, fine for them. I like to know the question (code), to learn things..(Not for only me, for other fellow Ranchers too). So its better, to provide the code, so that peoples like me ( who don't have a book ) gain some knowledge.

Rashmi Jaik wrote:

Sagar Rohankar wrote:
I should have made it more obvious. No regrets.



Yes, you should..

 
Rashmi Jaik
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the book because it explains things clearly in a way I can understand. It is hard to understand things out of context.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic