• Post Reply Bookmark Topic Watch Topic
  • New Topic

How is it possible?  RSS feed

 
Shivi Kashyap
Greenhorn
Posts: 16
Java Redhat Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i came to know that in List<Integer> list=new ArrayList<Integer>(); 'List' is an interface and we're creating an instance of that interface with ArrayList class. Kindly tell me how can it be possible to create an instance of interface?How it can be possible? thanks in advance
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An "instance of an interface" is an instance of any class which can be assigned to a variable of the interface type, which means an instance of any class which implements the interface.

In your example ArrayList is a class which implements the List interface.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!