File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt

 
gangashri patil
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is difference between 1] List a=new List
2]ArrayList a=new ArrayList

which one is good to use?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

java.util.List is an interface, so the first option is not going to work, because you can't instantiate an interface using new.

But probably you meant: List a = new ArrayList();

You're not the first one who asks this question, in fact, it is asked regularly on the forums here. It's the program to an interface, not an implementation principle.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic