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

  • SEARCH
  • Home
  • 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 613657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:01:36+00:00 2026-05-13T18:01:36+00:00

(1) List<?> myList = new ArrayList<?>(); (2) ArrayList<?> myList = new ArrayList<?>(); I understand

  • 0
(1) List<?> myList = new ArrayList<?>();

(2) ArrayList<?> myList = new ArrayList<?>();

I understand that with (1), implementations of the List interface can be swapped. It seems that (1) is typically used in an application regardless of need (myself I always use this).

I am wondering if anyone uses (2)?

Also, how often (and can I please get an example) does the situation actually require using (1) over (2) (i.e. where (2) wouldn’t suffice..aside coding to interfaces and best practices etc.)

  • 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-13T18:01:37+00:00Added an answer on May 13, 2026 at 6:01 pm

    Almost always List is preferred over ArrayList because, for instance, List can be translated into a LinkedList without affecting the rest of the codebase.

    If one used ArrayList instead of List, it’s hard to change the ArrayList implementation into a LinkedList one because ArrayList specific methods have been used in the codebase that would also require restructuring.

    You can read about the List implementations here.

    You may start with an ArrayList, but soon after discover that another implementation is the more appropriate choice.

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

Sidebar

Related Questions

I have a list like that: private List<T> myList = new ArrayList<T>(); I want
Somewhere I saw a java.util.List defined as below. List<String> myList = new ArrayList<String>(0); Can
I have something like @XmlElementWrapper(name=Mylist) List<Items> myItems = new ArrayList<Items>() and that comes out
I have a Arraylist List<?> myList=new ArrayList(); myList = fetchQuery(); //fetches the list of
List<Object> myList = new ArrayList<String>(); //(hint: no) Map<Integer> myMap = new HashMap<int>(); // (hint:
I have one customized list MyList that extends ArrayList, like this: class MyList extends
There is a list: List<Integer[]> myList = new ArrayList<Integer[]>(); It contains a sigle entry,
Consider this sample code: List<String> myList = new ArrayList<String>(7); myList.add(5, Hello); myList.removeAll(Collections.singleton(null)); System.out.println(myList.size() +
ArrayList<MyClass> myList = new ArrayList<MyClass>(); ListView listView = (ListView) findViewById(R.id.list); ArrayAdapter<MyClass> adapter = new
I have one list: List<Object> myList = new ArrayList<Object>(); To get from this list

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.