티스토리 뷰
Collection framework 에는 ArrayList처럼 순차적으로 data를 저장시키는 컬렉션이 있는 반면, hashSet과 같이 데이터의 순서가 무시되는 컬렉션도 존재하기에 element를 알아내기 위해서는 Iterator method를 사용해야한다.
hasNext() - return true. if there is element left inside the iteration
next() - return next element
previous() - return the previous element
remove() - remove next element
Example code
Iterator<PhoneInfo> itr = phoneInfo.iterator(); //iterate phoneInfo
while (itr.hasNext()) { //return true until no more elements left to iterate
PhoneInfo curInfo = itr.next();
if (name.compareTo(curInfo.name) == 0) {
itr.remove();
System.out.println("deleted");
return;
}
}
|
'JAVA' 카테고리의 다른 글
for each (0) | 2019.07.13 |
---|---|
Returning ArrayList from Method (0) | 2019.07.13 |
Check only integer input (0) | 2019.07.12 |
instanceof keyword (0) | 2019.07.11 |
Overriding hasCode() and equals() in Java (0) | 2019.07.11 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- ... in Javascript
- math.abs
- algorithm
- code refactoring
- Object type casting
- math.max
- 프로그래머스
- HackerRank Algorithm
- compareTo()
- spring boot application
- hackerrank javascript solution
- java
- easy javascript algorithm
- 알고리즘
- HashMap
- 프로그래머스 알고리즘
- Javascript Algorithm
- Collection Framework
- hackerrank
- repeat()
- hackerrank solution
- hackerrank javascript
- substring()
- 프로그래머스 알고리즘문제
- equals()
- string class in java
- javascript
- C++
- easy algorithm
- rest parameter
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
글 보관함