기타-프로그래밍
NoSuchElementException
jwstory.com
2008. 3. 3. 13:40
반응형
java.util에 보면 NoSuchElementException이 있습니다.
오늘 Tool만드는 중 Error가 나서 Note합니다.
보통 우리가 Collection 의 값을 가져올때 hasNext()를 사용합니다.
그런데 hasNext() 후 Next()를 이용하여 값을 가져오려 할 때 많이 Loop 내에 또 Loop를 돌려 hasNext() 할때에는 값이 있다가 Next 할때 값이 없는 상태가 되어 버리면 NoSuchElementException 이 발생합니다.
한마디로 다음의 요소가 없어서 Exception이 난 것입니다.
Thrown by the nextElement method of an Enumeration to indicate that there are no more elements in the enumeration.
오늘 Tool만드는 중 Error가 나서 Note합니다.
보통 우리가 Collection 의 값을 가져올때 hasNext()를 사용합니다.
그런데 hasNext() 후 Next()를 이용하여 값을 가져오려 할 때 많이 Loop 내에 또 Loop를 돌려 hasNext() 할때에는 값이 있다가 Next 할때 값이 없는 상태가 되어 버리면 NoSuchElementException 이 발생합니다.
한마디로 다음의 요소가 없어서 Exception이 난 것입니다.
Thrown by the nextElement method of an Enumeration to indicate that there are no more elements in the enumeration.
반응형