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
- Book review
- program
- web
- Malaysia
- history
- QT
- ubuntu
- Programming
- comic agile
- Book
- hbase
- RFID
- essay
- MySQL
- Software Engineering
- Italy
- Kuala Lumpur
- Linux
- France
- hadoop
- programming_book
- django
- Artificial Intelligence
- Java
- erlang
- management
- leadership
- AI
- agile
- Python
Archives
- Today
- Total
remove null reference in Java List 본문
http://stackoverflow.com/questions/1239579/helper-in-order-to-remove-null-reference-in-java-list
import java.util.*;
public class ListTest
{
public static void main(String[] args)
{
final List<Integer> iList = new ArrayList<Integer>();
for ( int i = 0; i < 10; ++i ) {
if ( i % 2 == 0 ) iList.add(i);
else iList.add(null);
}
iList.remove(0);
System.out.println(iList + "\tsize " + iList.size());
iList.removeAll(Collections.singletonList(null));
System.out.println(iList + "\tsize " + iList.size());
}
}
Comments