-3

In java collections, Since List is an interface and how the "new" keyword is used to declare it without any anonymous class.

Please explain how the following line works. List listTry= new ArrayList();

How the instance is created for ArrayList interface.

Prasanna
  • 11
  • 3

1 Answers1

0

List listTry= new ArrayList();

This line assign an ArrayList object into List reference.

ArrayList is a child class of List, and able to create object.

Johnny Ngo
  • 104
  • 4
  • I got an answer thanks. https://stackoverflow.com/questions/17400664/can-i-create-object-for-interface – Prasanna May 28 '18 at 09:40