개발일지
Apex Collection List, Set, Map 본문
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>
'Apex' 카테고리의 다른 글
Salesforce APEX Excetion Limit 모음 (0) | 2025.01.22 |
---|---|
Apex에서 종속 선택 목록 값 가져오기 (0) | 2025.01.20 |
List 형식의 query문을 담고 리턴으로 List반환(데이터테이블에 목록출력) (0) | 2021.07.09 |