This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Slaxmi Raj
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10427
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49411
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The raw type version might be easier to visualise.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic