'Iterator'에 해당되는 글 1건

  1. 2011.01.07 java.util.ConcurrentModificationException (8)
iterator 사용시에 iterator 구동되는 동안에 insert, update, delete 를 시도하면 ConcurrentModificationException 이 발생합니다.

iterator 가 부모의 내용이 변경되지 않는 것을 전제로 하기 때문인데, 이 때 Iterator 로 빼낼 객체의 clone 을 만들어서 사용하면 해결됩니다.

Iterator it = ((ArrayList<String>)list.clone()).iterator();
while(it.hasNext()) {
    it.remove();
}


Posted by 행복한 프로그래머 궁금쟁이박

댓글을 달아 주세요

  1. 스파게티코더 2011.01.07 22:25  댓글주소  수정/삭제  댓글쓰기

    clone을 하면 deep copy를 하는 것인가?
    아니면 인스턴스의 레퍼런스만 추가하는거?

  2. BlogIcon 박상구 2011.01.11 13:06  댓글주소  수정/삭제  댓글쓰기

    얘기했듯이 셸로우 카피 인가벼.ㅎ

  3. 지나가던 공돌이 2011.07.26 10:31  댓글주소  수정/삭제  댓글쓰기

    덕분에 에러를 하나 해결했습니다. 감사합니다.

  4. BlogIcon 피의화요일 2011.12.22 11:01 신고  댓글주소  수정/삭제  댓글쓰기

    상현아 올만이다.
    오류 난거 찾다보니 네 블로그까지 왔구나 ㅋㅋㅋㅋ

  5. BlogIcon Gucci Guccissima 2012.08.21 16:54  댓글주소  수정/삭제  댓글쓰기

    이 문서는 위대한 작성

  6. 장원준 2012.10.01 16:11  댓글주소  수정/삭제  댓글쓰기

    http://docs.oracle.com/javase/tutorial/collections/interfaces/collection.html
    iterator.remove 를 쓰는게 정석이라고 나오는 구만 ^-^

  7. BlogIcon sweertate 2013.07.02 19:30  댓글주소  수정/삭제  댓글쓰기

    sdfsdfsdfsdfsdfsdfsdfsdfsdf

  8. BlogIcon sweertate 2013.07.04 00:59  댓글주소  수정/삭제  댓글쓰기

    For anybody who values comfort over glamour, flip flops are heaven-sent. No other type of footwear is more comfortable. They are available in every color and can be made out of any material. You can have a pair to use at home, and more classy ones for social engagements.
    Past designs of flip flops were not very foot-friendly. A wearer would often need a few weeks to get used to a pair. Fortunately, modern footwear manufacturers have incorporated comfort in their designs making flip flops more popular. They can now be found in homes throughout out the world.
    Being easy to slip-on and off is just one of the lovely attributes of flip flops. It doesnt matter if they get wet and they allow women to show off their newly painted toenails. Their popularity has prompted almost all footwear companies to manufacture them.
    Some expensive models are available for brand-conscious individuals and some less costly models are available for thrifty costumers. It all depends on you; you can wear what kind of flip flops that satisfy your taste. But no matter how much they cost, they are still adored by countless consumers.
    It would be wonderful if society allowed people to wear flip flops whenever and wherever they went to. Unfortunately they are not allowed at workplaces and are considered to be informal by fashion authorities, limiting the places where you can wear them. I think that our feet would really appreciate it we could wear them more often.
    If you walk through any department store or shoe store and you notice the tons of sandals available. You'll notice that flip flops come in every color and material, which you could easily view in display in most living rooms. They may vary in price range and but are still a girls best friend.