I have a map Map<Id, list<Boolean>> mapOfIdAndListBoolean = new Map<Id, list<Boolean>>(); I think I can get the whole list by using mapOfIdAndListBoolean .get(order.AccountId). Would I get the first element of the list by using mapOfIdAndListBoolean .get(order.AccountId)[0]?

1 Answer 1


Yes you will get the first element of the List.

Try below code for understanding in anonymous window.

Map<String, list<Boolean>> mapOfIdAndListBoolean = new Map<String, list<Boolean>>();

mapOfIdAndListBoolean.put('testStr',new List<Boolean>{true,false,true});
Boolean value = mapOfIdAndListBoolean.get('testStr')[0];
  • But You need to be very sure that you will not get "null" for the "key" here. Otherwise, you run into Null Pointer Exception Oct 25, 2019 at 7:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .