[SalesForce] Execute anonymous unexpected token ‘<'

I receive this error:

Line: 5, Column: 4 unexpected token: '<'

When executing this code in the execute anonymous window in the developer console:

Map<String, List<Custom_Object__c>> idsToCustomObjectList = Map<String, List<Custom_Object__c>>();

Why do I get this error? How can I fix it?

Best Answer

The error is a little misleading. You are missing the new keyword when you assign idsToCustomObjectList.

Map<String, List<Custom_Object__c>> idsToCustomObjectList = new Map<String, List<Custom_Object__c>>();
Related Topic