2015년 12월 9일 수요일
[java]ArrayList for문 삭제시 문제점
//for문을 이용하여 삭제하면 동적으로 ArrayList 에 인덱스의 따른 데이터가 변경되므로 Iterator 인터페이스를 이용하여 삭제
ArrayList<AutoCallServiceVo> mData ...
AutoCallServiceVo 객체에는 boolean 타입의 isChecked 라는 변수가 존재한다.
public boolean CheckItemDelete(){
boolean result;
//혹시나 모르는 예외 처리..
try{
//mData.iterator() 를통해 ArrayList 로 부터 Iteraror 객체를 얻고
//for문이나 while 문에서 hasNext() 메소드를 통해
//인덱스를 신경 쓰지 않고 접근이 가능하다.
for(Iterator<AutoCallServiceVo> itr = mData.iterator(); itr.hasNext();){
if(itr.next().isChecked){
itr.remove();
}
}
result = true;
notifyDataSetChanged();
}catch(Exception e){
e.printStackTrace();
result = false;
}
return result;
}
피드 구독하기:
댓글 (Atom)
[lunux]리눅스 폴더별 용량 확인
리눅스 폴더별 용량 확인 조회 하고자 하는 디렉토리 리스트가있는 경로로 이동후 du -h --max-depth=1
-
pom.xml <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId&g...
-
수십대의 서버에 특정 쉘을 실행한다거나 파일을 수정해야할경우 호스트 입력 아이디 입력 패스워드 입력은 여간 짜증나는일이 아닐수 없다. 이를 한방에 해주는 방법 teraterm 를 설치한다( putty 는 버리자 ) 예를 들면 19...
-
자바에서 redis 를 사용할때는 jedis 라는 wrapping api 를 사용 하는데 기본 사용법은 메이븐에 아래 의존 라이브러리를 추가하고 <dependency> <groupId>redis.clients</g...
댓글 없음:
댓글 쓰기