Results 1 to 4 of 4
  1. #1
    ravian is offline Senior Member
    Join Date
    Nov 2007
    Posts
    115
    Rep Power
    0

    Default List and ArrayList

    Greetings,

    I understand tat List is an interface and ArrayList is a class that implements the List interface. I am not able to understand the difference bwtween the following two statements:

    Java Code:
    List myArr = new ArrayList();
    ArrayList myArr = new ArrayList();
    Thanks in advance.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    The general idea of why the first line is recommended over the second is given on this page Lesson: Implementations in the fifth paragraph following the "General-purpose Implementations" table, starting with: "As a rule, you should be thinking about the interfaces, not the implementations.";

  3. #3
    javagk is offline Member
    Join Date
    Nov 2007
    Posts
    12
    Rep Power
    0

    Default

    Thanks for sharing this. Its helped me.

  4. #4
    cdub is offline Member
    Join Date
    Jul 2011
    Posts
    1
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 04-21-2008, 11:43 AM
  2. ArrayList
    By ramitmehra123 in forum New To Java
    Replies: 1
    Last Post: 02-07-2008, 12:47 AM
  3. ArrayList
    By kizilbas1 in forum New To Java
    Replies: 1
    Last Post: 01-12-2008, 08:48 PM
  4. ArrayList
    By kizilbas1 in forum New To Java
    Replies: 11
    Last Post: 12-05-2007, 07:30 PM
  5. Help ArrayList.add()
    By eNine in forum New To Java
    Replies: 2
    Last Post: 08-06-2007, 01:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •