+ Start a Discussion
LionLion 

Reg: sets & lists

Hi,

 

I have both List & set of same type.

 

List<Integer> lst1=new List<Integer>{10,20,30,40};

Set<Integer> st1=new Set<Integer>{10,20};

 

My requirement is i would like to take the 30,40 (Not Common values) in another set or list...

 

 

Can any one help me..

 

Pradeep_NavatarPradeep_Navatar

Since set discards the duplicate value , so you can add elements of list to set.

List<Integer> lst1=new List<Integer>{10,20,30,40};

Set<Integer> st1=new Set<Integer>{10,20};

St1.addAll(lst1);

Now set has values 10,20,30,40.