Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. contact c1 = new contact(id='003000000089012', firstname='1', lastname='2', phone=null);
  2. contact c2 = new contact(id='003000000089012', firstname='1', lastname='2');
  3. contact c3 = new contact(id='003000000089012', firstname='1', lastname='2', phone='');
  4. contact c4 = new contact(id='003000000089012', firstname='1', lastname='3', phone='');
  5. contact c5 = new contact(id='003000000089012', firstname='1', lastname='3');
  6.  
  7. set<contact> contacts = new set<contact>();
  8. contacts.add(c1);
  9. contacts.add(c2);
  10. contacts.add(c3);
  11. contacts.add(c4);
  12. contacts.add(c5);
  13. for(contact c : contacts){
  14. system.debug('5 Items: '+c);
  15. }
  16. system.debug('5 Items BREAK');
  17.  
  18. c1.phone='';
  19.  
  20. for(contact c : contacts){
  21. system.debug('Same : '+c);
  22. }
  23. system.debug('Same BREAK');
  24.  
  25. contacts.add(c1);
  26.  
  27. for(contact c : contacts){
  28. system.debug('c1 Added: '+c);
  29. }
  30.  
  31. system.debug('c1 Added BREAK');
  32.  
  33. contact c6 = new contact(id='003000000089012', firstname='1', lastname='2', phone='');
  34. contacts.add(c6);
  35.  
  36. for(contact c : contacts){
  37. system.debug('New Same: '+c);
  38. }
  39. system.debug('New Same BREAK');
  40.  
  41. contacts.addall(contacts);
  42.  
  43. for(contact c : contacts){
  44. system.debug('Addall: '+c);
  45. }
  46. system.debug('Addall BREAK');
  47.  
  48. set<contact> cnts2 = new set<contact>();
  49. cnts2 = contacts.clone();
  50.  
  51. for(contact c : cnts2){
  52. system.debug('Clone: '+c);
  53. }
  54. system.debug('Clone BREAK');
  55.  
  56. set<contact> cnts3 = new set<contact>();
  57. cnts3.addall(contacts);
  58.  
  59. for(contact c : cnts3){
  60. system.debug('New Addall: '+c);
  61. }
  62. system.debug('New Addall BREAK');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement