• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt in ArrayList Basics

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a doubt in arraylist topic from K&B scjp6 book. in objective 6.3 "ArrayList" Basics there will be a line

List<String> myList = new ArrayList<String>();
"This kind of declaration follows the object oriented programming principle of 'coding to an interface', and it makes use of generics."

Please clarify my doubt "List is an interface" and "ArrayList" is a class which implements "List" interface and why we are using "new" keword in the above statement. I know its a very basic question, as am a beginner please clarify my doubt.

Thanks.
 
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can probably get an understanding by reading this post >> Interface Concept in Java
As well as this post >> Interface
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"new" instantiates a new object. So that code creates a new object of (concrete class) ArrayList. It then stores a reference to that object in the List interface variable.
 
dayalan kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you All for the reply.

 
reply
    Bookmark Topic Watch Topic
  • New Topic