File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Cast to interface reference and the class refernece that implementing the interface.is it possible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cast to interface reference and the class refernece that implementing the interface.is it possible?" Watch "Cast to interface reference and the class refernece that implementing the interface.is it possible?" New topic
Author

Cast to interface reference and the class refernece that implementing the interface.is it possible?

Slaxmi Raj
Ranch Hand

Joined: Apr 20, 2012
Posts: 40
Can any one please explain the below statement with example(Not getting to my knowledge because i am the beginner).
A reference variable can be declared as a class type or an interface type. If
the variable is declared as an interface type, it can reference any object of any
class that implements the interface.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7024
    
  16

Slaxmi Raj wrote:Can any one please explain the below statement with example(Not getting to my knowledge because i am the beginner)...

List<String> = new ArrayList<String>();

Winston
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
The raw type version might be easier to visualise.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cast to interface reference and the class refernece that implementing the interface.is it possible?
 
Similar Threads
OO enunciate
question about declare and create an object
Difference Between These 2 Declarations.
Reference variable concepts
whats the difference between Objects and reference variables?