aspose file tools*
The moose likes Beginning Java and the fly likes Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt" Watch "Doubt" New topic
Author

Doubt

gangashri patil
Greenhorn

Joined: Sep 21, 2011
Posts: 3
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

Joined: Aug 16, 2005
Posts: 14268
    
  21

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt