• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why in collection Objects are assigned to super reference  RSS feed

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

In collection i saw where they are recommanding to use List l= new ArrayList();
why not ArrayList l= new ArrayList();

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
List is not the "super" of ArrayList -- it's the implemented interface. And why you should code against the interfaces has been covered many times in this forum. Please search for those discussions.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a frequently asked question; have a look at this older topic which contains links to more answers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!