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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:12:13+00:00 2026-06-12T17:12:13+00:00

I declare the private variable as private List<MultipartFile> files; When I want initialize it

  • 0

I declare the private variable as

private List<MultipartFile> files;

When I want initialize it I do in this way:

files=new ArrayList<CommonsMultipartFile>();

you can see the CommonsMultipartFile extends the MultipartFile Interface
The compile give me error as:

Type mismatch: cannot convert from ArrayList<CommonsMultipartFile> to List<MultipartFile>

Anyone who know the reason?
If I really want to Stable the collection and inside class type, how can I do it?
Can I do similar staff in C++?

  • 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-06-12T17:12:14+00:00Added an answer on June 12, 2026 at 5:12 pm

    If im not mistaken, in java generics :

    If you have two class A, class B extends A and a generic class Generic<T>, then Generic<B> does not extends Generic<A>. That’s why your cast does not work.

    You could declare files as :

    private List<? extends MultipartFiles> files;
    

    With this, you should be able to do your assignment.

    Edit : As it’s said in other response, this declaration would prevent to add other things than null. Limited interest indeed…

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

Sidebar

Related Questions

I have a variable declared as: private static List<String> _search_result_list = new ArrayList<String>( 15
How can I declare a list of objects in php as a private instance
I can declare private static member variables in a class, but what does it
as you can see the class below declares 2 private instance variables and 2
I'm evaluating selfish and am wondering how I can declare private methods/fields?
I declare array like that private double[] array = new double[length] . Is it
Right now, I have to do this private delegate void set(int obj); //declare the
I noticed some people declare a private variable and then a public variable with
Should we declare the private fields as volatile if the instanced are used in
I am trying to declare a private Data Structure such as the Vector in

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.