function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BinayakBinayak 

Internal System Error in populating map

I have a small piece of code:

 


Map<List<String>,String> mapLstStr =  new Map<List<String>,String>();
List<String> lst1 = new List<String>();
List<String> lst2 = new List<String>();

lst1.add('A');
lst1.add('B');

lst2.add('A');
lst2.add('C');

mapLstStr.put(lst1,'ABCD');
mapLstStr.put(lst2,'ABCDE');

System.debug('****'+mapLstStr);

 

 

When i execute it in developer console,its showing 'Internal System Error: 1311241958-36767 (-1213750749)'.Can anybody please help me to debug this piece.

'

PremanathPremanath

Hi it cannot print total list

Try this code

 

Map<List<String>,String> mapLstStr = new Map<List<String>,String>();
List<String> lst1 = new List<String>();
List<String> lst2 = new List<String>();

lst1.add('A');
lst1.add('B');

lst2.add('A');
lst2.add('C');

mapLstStr.put(lst1,'ABCD');
mapLstStr.put(lst2,'ABCDE');

System.debug('****'+mapLstStr.get(lst1));

 

Prem

Jia HuJia Hu
This is a little strange, only

System.debug('****'+mapLstStr); got the error, like,

An internal error occurred during: "Execute-Anonymous". java.lang.NullPointerException

All the other methods of Map are fine.
SeAlVaSeAlVa

Try the other way around

Map<String,List<String>> mapLstStr =  new Map<String,List<String>>();
List<String> lst1 = new List<String>();
List<String> lst2 = new List<String>();

lst1.add('A');
lst1.add('B');

lst2.add('A');
lst2.add('C');

mapLstStr.put('ABCD',lst1);
mapLstStr.put('ABCDE',lst2);

System.debug('****'+mapLstStr);

 Regards

BinayakBinayak

Sorry, it to be meant that way only.Say suppose we want to create a map of 2 master objects and the related junction object.So in the list it will contain the 2 master objet's id (as a key) and the string as the junction objects's id (as a value).

SeAlVaSeAlVa

What about...

Map<Set<String>,String> mapLstStr =  new Map<Set<String>,String>();
Set<String> set1 = new Set<String>();
Set<String> set2 = new Set<String>();

set1.add('A');
set1.add('B');

set2.add('A');
set2.add('C');

mapLstStr.put(lst1,'AB-Relationship');
mapLstStr.put(lst2,'AC-Relationship');

System.debug('****'+mapLstStr.get(new Set<String>{'B','A'})); /* B,A is the relationship searched, that can also be a variable like "Set<String> searched = new Set<String>{'A','B'};" or declared as set1 or set2*/