Posts

Showing posts from January, 2018

DIFFERENCE BETWEEN SET, LIST AND MAP

Three different types of collections in Apex. List Set Map List : List simply called collection of duplicate values and which contains Integer indexed data. Create new  LIST . List<String> myList = new List<String>(); Add into  LIST . myList.add(‘Navin’); myList = new List<String>{ ‘Navin’, ‘Aryan’ }; Duplicate means? myList.add(‘Navin’); myList.add(‘Aryan’); myList.add(‘Navin’); Here the size of LIST is 3 . We can get this by myList .size() At index 0, myList[0] = we get Navin At index 1, myList[1] = we get Aryan At index 2, myList[2] = we get Navin Set : Set simply called collection of Unique values and cannot be sort. Create new SET. Set<String> mySet = new Set<String>(); Add into Set. mySet .add(‘Navin’); mySet = new mySet <String>{ ‘Navin’, ‘Aryan’ }; Unique means? mySet.add(‘Navin’); mySet.add(‘Aryan’); mySet.add(‘Navin’); Here the size of SET is 2 . We can get this...