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 3394898
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:13:31+00:00 2026-05-18T04:13:31+00:00

I am trying to create a list of list of strings, List<List<String>> string= new

  • 0

I am trying to create a list of list of strings,

List<List<String>> string= new ArrayList<ArrayList<String>>();

and getting Type Mismatch error:cannot convert from ArrayList<ArrayList<String>> to List<List<String>>.

I know I can change

List<List<String>> to ArrayList<ArrayList<String>>

and it will work fine.

But I was just wondering why doesn’t it let it happen? Simple List<Object> can refer to ArrayList<Object> so what is different about this?

  • 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-18T04:13:31+00:00Added an answer on May 18, 2026 at 4:13 am

    Because a List<List<String>> would accept other lists of strings that were not array lists, which is not how you declared the type initially. For example, if you converted to a List<List<String>>, you would technically be allowed to add a LinkedList<String> to it! And that’s not an ArrayList<String>. Allowing that cast would effectively break the generic type system.

    In other words, you could convert to List<ArrayList<String>>. But not List<List<String>>.

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

Sidebar

Related Questions

Why this code comes out an error? List<String>[] l = new ArrayList<String>[10]; Eclipse said
I'm trying to create a list of tasks that I've read from some text
I am trying to create a list of a certain type. I want to
I am trying to create a list that adds a new row of data
Trying to create a list to return some JSON data to a view. Following
I'm trying to create a list that some of the elements are defined and
I am trying to create a list box that displays a set of data
I've been trying to create a list definition based on the SharePoint Discussion Board
I'm currently trying to create a list of 5 blog titles of mine, where
I have an the following class I'm trying to create a list of with

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.