Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Python
- web
- management
- MySQL
- QT
- Java
- erlang
- Book review
- history
- essay
- program
- django
- Linux
- Italy
- Spain
- agile
- France
- leadership
- comic agile
- Malaysia
- psychology
- RFID
- hbase
- programming_book
- hadoop
- Programming
- Software Engineering
- Kuala Lumpur
- Book
- ubuntu
Archives
- Today
- Total
Iterable, Iterator 본문
// http://blog.naver.com/enternow/120027291479 // http://www.java2s.com/Code/JavaAPI/java.util/implementsIteratorCharacter.htm import java.util.Iterator; public class TestIterableIterator implements Iterable<Character>, Iterator<Character> { private final String text; public TestIterableIterator(String text) { this.text = text; } public Iterator<Character> iterator() { return this; } private int curr = 0; public boolean hasNext() { if ( curr < text.length() ) return true; return false; } public Character next() { return text.charAt(curr++); } public void remove() {} public static void main(final String[] args) { TestIterableIterator t = new TestIterableIterator("가나다라"); for ( final Character c : t ) System.out.println(c); t = new TestIterableIterator("가나다라"); for ( Iterator<Character> c = t.iterator(); t.hasNext(); ) System.out.println(c.next()); } }
Comments