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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:03:02+00:00 2026-05-28T03:03:02+00:00

So I have a Map that has some values in it being passed into

  • 0

So I have a Map that has some values in it being passed into a method:

public String doThis(Map<String, ?> context){
.....
}

And I’m trying to insert an addition attribute to this Map

String abc="123";
context.put("newAttr",abc);

But I am getting this error:

The method put(String, capture#8-of ?) in the type Map is not applicable for the arguments (String, String)

Is there anyway to perform this put without “cloning” the Map?

  • 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-28T03:03:02+00:00Added an answer on May 28, 2026 at 3:03 am

    If you want to put values of type X into a generic Map you need to declare the Map as Map<String, ? super X>. In your example X is String, so:

    public String doThis(Map<String, ? super String> context){
    .....
    }
    

    Map<String, ? super X> means: a map with keys of type String and values of a type which is X or a super-type of X. All such maps are ready to accept String instances as keys and X instances as values.

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

Sidebar

Related Questions

In a controller, I have populated a map that has a string as key
I want to have a map that has a homogeneous key type but heterogeneous
So I have an excel workbook that has a nice global map of shaperange
I have a std::map that I'm using to store values for x and y
I have a pointer to a map that I am trying to delete (this
I have a database that accepts no null values and has a default for
I have bean MyBean, which has property HashMap - map which values type is
I'm trying to accomplish the following. I have a DTO that returns values from
I'm sticking some data, wrapped with boost::any into a map in a class method
Say I have a very simple java object that only has some getXXX and

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.