i am unable to fetch all Keys and Value simultaneously using forEach loop..
for (Map<String,String> key : parameters) {
queryParameters = key.values();//?
}
i am unable to fetch all Keys and Value simultaneously using forEach loop..
for (Map<String,String> key : parameters) {
queryParameters = key.values();//?
}
Best Answer
If you want to fetch them all simultaneously, you have to do it outside the loop:
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_map.htm
If you absolutely need to all the keys inside a
for
loop (I don't know why... it sounds like bad practice to reference keys other than the one you're currently iterating), you can reference themapKeys
variable inside the for loop.Or, just iterate and reference them one at a time as @MSCB described above