Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

개발일지

Apex Collection List, Set, Map 본문

Apex

Apex Collection List, Set, Map

청일쓰 2021. 7. 9. 09:54

List 

인덱스 번호를 기반으로 목록 요소를 식별하려는 경우

 

List accList = new List();


Set

Set은 순서가 지정되지 않은 컬렉션.
1) 중복 요소를 포함하지 않습니다. 따라서 컬렉션에 중복이 포함되지 않도록 하려면 set을 사용

예: Set<Account> accSet = new Set<Account>()

Set<String> setString = new Set<String>(); // 두 개의 문자열을 추가
setString .add('item1');
setString .add('item2');


Map : 맵은 키-값 쌍의 모음입니다. 
각 고유 키는 단일 값에 매핑됩니다. 키는 모든 기본 데이터 유형이 될 수 있고 값은 기본, sObject, 컬렉션 유형 또는 Apex 개체가 될 수 있습니다.

 

Map<id, account=""> accMap = new Map<id, account="">();</id,></id,>

Map<integer, string=""> mapOfString = new Map<integer, string="">();</integer,></integer,>
mapOfString.put(1, 'Amit');
mapOfString.put(2, 'Rahul');
System.assert(mapOfString.containsKey(1)); 
String value = mapOfString.get(2); 
System.assertEquals('Rahul', value); Set s = mapOfString.keySet();
Map<string, string> myMap = new Map<string, string>{'a' => 'b', 'c' => 'd'};</string, string></string, string>