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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:58:34+00:00 2026-05-27T21:58:34+00:00

List<Integer> ints = Arrays.asList(1,2,3,4,5); List<Double> doubles = Arrays.asList(226.6131 , 7789879.3 ); List<Long> longs =

  • 0
List<Integer> ints = Arrays.asList(1,2,3,4,5);
List<Double> doubles = Arrays.asList(226.6131 , 7789879.3  );
List<Long>  longs  = Arrays.asList( 687643643687L , 743926945627L );
List<List<?>> lists =  Arrays.asList(ints, doubles , longs); // Type mismatch: cannot convert from List<List<? extends Number&Comparable<?>>> to List<List<?>> 
List<List<? extends Number & Comparable<?>>> lists =  Arrays.asList(ints, doubles , longs); // Syntax error on token "&", , expected

I am trying to create a List of Lists as the code above shows. First I have 3 lists , each of which stores elements that extends Number implements Comparable. Next I want to put the 3 lists into another List , but I am not able to do this.

List<List<?>> lists =  Arrays.asList(ints, doubles , longs); 

This line gives compiler error saying cannot convert from List<List<? extends Number&Comparable<?>>> to List<List<?>> .

When I try to modify the type of reference in next line , there is a syntax error.
How do I get the 3 lists above ( ints , doubles and longs ) into another List<> ?

Edit : A related question :
What is correct syntax of declaring a List of Lists of elements that extends Number AND implement Comparable ?

  • 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-27T21:58:35+00:00Added an answer on May 27, 2026 at 9:58 pm

    i believe you want something like:

    List<? extends List<?>> lists =  Arrays.asList(ints, doubles , longs);
    

    you can use this form for more type safety:

    List<? extends List<? extends Number>> lists =  Arrays.<List<? extends Number>>asList(ints, doubles , longs);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this code: List<Integer> ints = new ArrayList<Integer>(); // Type mismatch: // cannot convert
This works to return a list of ints: public List<Integer> GetIListImpl() { return new
Integer[] ints = list.toArray(new Integer[]{}); If I remove {} the compiler asks to fill
What is reason behind supporting the syntax below on java 1.7 List<Integer> ints=new ArrayList<>();
testGroupList is a list of integer. I need to check the numbers in testGroupList
I created an integer list and am trying to return the index of a
I have a generic list of integer and it contains random numbers. How would
I want to sort a list of integer values, but before sorting them I
I want to write a structure which has a list of integer id. The
I have a list of nullable integer and it look like a 1 to

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.