Tuesday, 1 January 2013

 Adding data to sets in apex, A small mistake that made me disappointed for a complete day.

In sets we have a built in function to add data to that sets

Eg: Set<String> Str;


But be careful that we should create  one instance otherwise salesforce won't allow you to insert data to this sets.

Also salesforce will not generate any compile time waring or error message while saving the code.

The right code for the above example is below

Set<String> Str =  new Set<String>();

Even though it's a blunder sometimes we might forget about this. 

No comments:

Post a Comment