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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:49:19+00:00 2026-05-24T19:49:19+00:00

List<String>[] stringList = new List<?>[10]; gives Type mismatch: cannot convert from List<?>[] to List<String>[]

  • 0
  1. List<String>[] stringList = new List<?>[10];
    gives Type mismatch: cannot convert from List<?>[] to List<String>[]

  2. If i use following statement
    List<? extends Number> inLi = new ArrayList<Integer>();
    then inLi. inLi.add(5); gives The method add(int, capture#1-of ? extends Number) in the type List<capture#1-of ? extends Number> is not applicable for the arguments (int)

  • 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-24T19:49:21+00:00Added an answer on May 24, 2026 at 7:49 pm

    No. 1 doesn’t work, because List<String>[] means an array of String lists, while List<?>[] means an array of lists of anything. In a List<String>[] array, you can not have a List<Integer> element, but List<?>[] could have an element that’s a List<Integer>, hence the type mismatch error.

    In short, in Java it is not possible to create a generic array like this:

    Foo<T>[] fooArray = new Foo<T>[];
    

    But you can create a generic array like this:

    @SuppressWarnings("unchecked") // optional but informs the compiler 
                                   // not to generate warning message
    List<String>[] stringList = new ArrayList[10];
    

    For more information see this.

    Regarding 2, see this.

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

Sidebar

Related Questions

I have the following code: // Form the continuities list string[] continuities = new
Would the following: Dim stringlist As List(Of String) Dim stringlisthas = stringlist.Contains(thing1) be any
I have; List<String> stringList = new ArrayList<String>(); List<Integer> integerList = new ArrayList<Integer>(); Is there
If I have a simple list of Strings: List<String> stringList = new ArrayList<String>(); I
how does one convert from a list of characters to a string? To put
I have a class like this public SomeClass { private List<string> _strings = new
I have a String list ArrayList<String> list = new ArrayList<String>(); with each item: list.add(week+
ArrayList<Object> list = new ArrayList<Object>(); list.add(1); list.add(Java); list.add(3.14); System.out.println(list.toString()); I tried: ArrayList<String> list2 =
I have a jagged array that looks like this: string[][] list = new string[d.Rows.Count
I have a String List with items like this Root Root/Item1 Root/Item2 Root/Item3/SubItem1 Root/Item3/SubItem2

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.