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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:06:50+00:00 2026-06-08T05:06:50+00:00

Hello Folks I have a small query regarding Maps in Apex. I have a

  • 0

Hello Folks

I have a small query regarding Maps in Apex. I have a map map <String, list <Account>>. I am trying to do the following –

What needs to be done: I am passing a key to string variable and then passing that string to a Map.get() method to get the values for that key. Here, it does not give me the right answer. Even when I print out the Map using System.Debug() it prints out the map very differently!

String Id = 'Some Id that is the key in the map';
List <Account> testList = Map.get(Id);

This does not give me the corresponding value and I do not know why!

BUT

when I type the below code, the values are printed out perfectly.

for(String s : Map.keySet()){
   List <Account> TestList = Map.get(s);
   System.Debug('TestList' + TestList);
}

The Test list actually prints out what it is supposed to print out i.e. for each key it prints out the values where as when I print the map it does not print out as expected.

What is expected: I want to pass a key to the Map.get() method to retrieve the results but its clearly not happening in my case.

Any kinds of help is really appreciated!

  • 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-08T05:06:52+00:00Added an answer on June 8, 2026 at 5:06 am

    The only two things I can think of here are:

    • It’s a case issue. To verify, convert your keys to uppercase:

    theMap.put(stringKey.toUpperCase(), theAccountList);

    • By using Id as a variable name (itself a type), you are getting strange results

    As others have already mentioned here, please post the actual code segment so we can help further or close this issue.

    Thanks

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

Sidebar

Related Questions

Hello Folks, I have a list which has values from a query. The list
Hello folks :) I have a quick question - For the following NSMutableArray: NSMutableArray
Code can be found here: http://www.myhorizon.ca/client_central/sortable_test.php Hello folks of Stackoverflow, I have a list
Hello Folks, I am really new to Apex Development and currently trying to write
hello friends i am trying to get a list of user id and want
Hello folks! Could you tell me a good(non-redundant) way to find out the following:
Hello kind folks of StackOverflow. I am trying to make a sort of 'bot'
Hello I have a double linked list set up, and i have a search
Hello following problem, i need the id attribute string for each div in a
Hello guys I am working on silverlight and I have issue regarding on database

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.