Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1079701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:54:40+00:00 2026-05-16T21:54:40+00:00

ArrayList aList = new ArrayList(); List aList = new ArrayList(); What’s the difference between

  • 0
ArrayList aList = new ArrayList();

List aList = new ArrayList();

What’s the difference between these two and which is better to use and why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:54:41+00:00Added an answer on May 16, 2026 at 9:54 pm

    List<T> is interface, where ArrayList<T> is class, and this class implements List<T> interface.

    I would prefer 2nd form, which is more general, ie if you do not use methods specific to ArrayList<T> you can declare its type as interface List<T> type. With 2nd form it will be easier to change implementation from ArrayList<T> to other class that implements List<T> interface.

    EDIT:
    As many of SO users commented both forms can be arguments to any method that accept List<T> or ArrrayList<T>. But when I declare method I would prefer interface:

     void showAll(List <String> sl) ...
    

    and use:

     void showAllAS(ArrayList <String> sl) ...
    

    only when my method uses method specific to ArrayList<T>, like ensureCapacity().

    Response with information that we should use typed List<T> instead of just List is very good (of course if we do not use ancient Java).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 532k
  • Answers 532k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Don't use .toggle, as it won't provide you with what… May 17, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer You are close already. Just make sure to hide the… May 17, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer If these are NSManagedObjects, you want valueForKey:, not objectForKey: Like… May 17, 2026 at 12:15 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to make a list containing different objects. List<Object> list = new ArrayList<Object>();
List list = new ArrayList(); String[] test = {ram, mohan, anil, mukesh, mittal}; for(int
This works to return a list of ints: public List<Integer> GetIListImpl() { return new
Perhaps a stupid question: I have a List of type <Data> which I want
I've two issues currently preventing me from finishing two projects properly. I'll put them
I'm new to LINQ, and I have trouble with a query I'm trying to
I want to make a growable array of bytes. I.e a list. In c#
ok I have couple of .NET classes that I want to use in VBA.
In some code I'm creating a List of Bytes, and want to insert an
I have a list that gets refreshed every 2 seconds via the Handler postDelayed()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.