Javatpoint Logo

why we write List l=new ArrayList();

By: sudhir*** On: Tue Jul 25 19:28:05 IST 2017     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
Sorry, I am new to the java., so may be this is a stupid question.But have the doubt for below code
-why we write like below-
List l=new ArrayList(); //I feel if we write ArrayList l = new ArrayList(), and suppose in future I
//changed to LinkedList(), then somemethod() declaration has no impact,
// then why we give reference of the interface while we create an object of
//class??
someMethod(l);//method call

//method declearation
someMethod(List l){ //here understood the signifance of List interface,but in above it is not clear
//some logic
}
Up0Down