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

The Archive Base Latest Questions

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

I have a ConcurrentHashMap in the below format: ConcurrentHashMap<String,ConcurrentHashMap<String,ArrayList>> Now in this map,I want

  • 0

I have a ConcurrentHashMap in the below format:

ConcurrentHashMap<String,ConcurrentHashMap<String,ArrayList>>

Now in this map,I want to remove a particular value in the array list.Can anybody guide with this.

EDIT1:
I have a map
<“packet1”–><“NR1”,[Pr1,Pr2]>>
<“packet1”–><“NR2”,[Pr1,Pr2]>>

Now when i remove map.get(“packet1”).get(“NR1”).remove(“Pr2”) it removes Pr2 from both NR1 and NR2.Isnt should remove only from NR1.Am i doing anything wrong here.plz update me,

P.S : I am updated the map for the second time for the same key packet1 with both values NR1 and NR2

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

    You’ve made a mistake setting up the map. When you added the lists for NR1 and NR2, you used the same list object. Your map now contains two references to that list. When you remove the element from the NR1 list, you’re removing it from the same list that is visible under NR2.

    The solution is to fix your code, so that when you insert a list into the map, you insert a different list for each key.

    You say in a comment on JB’s post that you didn’t do this. The fact is, you did do this. You just haven’t realised it yet!

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

Sidebar

Related Questions

I have a variable: ConcurrentHashMap<String, List<AnObjectType>> mapOfList; The List as I understand is not
I have this code : public void GenerateWtW() { ExecutorService exec = Executors.newFixedThreadPool(30); ConcurrentHashMap<String,
is final Map<Integer,Map<String,Integer>> status = new ConcurrentHashMap<Integer, Map<String,Integer>>(); Map<Integer,Map<String,Integer>> statusInner = new ConcurrentHashMap<Integer, Map<String,Integer>>();
I have a class like the below and am wondering, will this be thread-safe
Have a xml string, goal is to replace an xml element value to a
Have some dates in my local Oracle 11g database that are in this format:
have an an array String classname[]={'a','b','c','d'}; ArrayAdapter<CharSequence> adapterClasses = new ArrayAdapter<CharSequence>( getApplicationContext(), R.layout.spinner_item_class, R.id.spinnerclasstxt,
The question came up when I saw this code: private static volatile ConcurrentHashMap<String, String>
Have you managed to get Aptana Studio debugging to work? I tried following this,
We have come across a strange issue with ConcurrentHashMap , where two threads appears

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.