// 1. 정보를 담아준다.
List<Map<String,Object>> dataMapList = (List) param.get("data");
// 2. 스트링 List에 data를 담아준다.
List<String> dataList = new ArrayList<String>();
// 3. 제거하고자 하는 data를 List에 넣어준다.
for(Map<String, Object> row : dataMapList ) {
dataList .add((String)row.get("code");
}
// 4 List에 담긴 내용을 중복 제거
List<String> newList = dataList.stream().distinct().collect(Collectors.toList());
위에 코드로 중복 제거하기도 하고 아래처럼 count를 사용하여 몇건이 중복 되었는지 확인도 가능하다.
// 1. 정보를 담아준다.
List<Map<String,Object>> dataMapList = (List) param.get("data");
// 2. 스트링 List에 data를 담아준다.
List dataList = new ArrayList();
List<String> dataList = new ArrayList<String>();
// 2-1. 중복 건수 변수 선언
int Cnt = 0 ;
int dupCnt = 0 ;
// 3. 제거하고자 하는 data를 List에 넣어준다.
for(Map<String, Object> row : dataMapList ) {
dataList .add((String)row.get("code");
Cnt += 1;
}
// 4 List에 담긴 내용을 중복 제거
List<String> newList = dataList.stream().distinct().collect(Collectors.toList());
// 5. 중복 건수 확인
dupCnt = Cnt - newList.size();
'개발에 유용한 Tip' 카테고리의 다른 글
레지스트리 변경 파일실행 (0) | 2024.04.04 |
---|---|
엑셀 VLOOKUP 사용법 초급자도 알기 쉽게 (0) | 2024.04.04 |
[CANIAS] COMBOBOX TEXT 추출 (0) | 2024.03.10 |
쿼리 정렬 (0) | 2024.03.09 |
[CANIS] 하단 풍선 팝업창 (0) | 2024.03.09 |