permaculture playing cards*
The moose likes Beginning Java and the fly likes java reference types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java reference types" Watch "java reference types" New topic
Author

java reference types

Adi Sharma
Ranch Hand

Joined: May 18, 2009
Posts: 33
I am preparing for SCJP and was reading the :

" method invocations allowed by the compiler are based solely on
the declared type of the reference, regardless of the object type. "

could anyone explain what it means ???

Thanks
Aditya Sharma
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36495
    
  16
It means that when you declare

Foo fff;
. . .
fff = new FooFoo(123, "abc");
. . .
fff.baa();

the compiler will only allow that baa() call if the Foo class has a method called baa. If the Foo class hasn't and the FooFoo class has, then the compiler will not allow that code to be compiled.
Adi Sharma
Ranch Hand

Joined: May 18, 2009
Posts: 33
Thanks a lot
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36495
    
  16
You're welcome
Peter Granstrom
Greenhorn

Joined: Jun 08, 2009
Posts: 10
thank you for your answer,
it helped me
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java reference types
 
Similar Threads
arrays & final
About type and class attribute of jsp usebean
reference problem
classCastException
overLoading