// 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();
'JAVA' 카테고리의 다른 글
| JAVA(Eclipse)에서 다빈치(DAVINCI) 호출 (0) | 2024.10.01 |
|---|