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 |
Tags
- essay
- programming_book
- France
- agile
- program
- django
- Python
- Programming
- Malaysia
- Spain
- Book
- MySQL
- history
- Artificial Intelligence
- web
- Java
- hadoop
- management
- hbase
- Software Engineering
- leadership
- RFID
- QT
- ubuntu
- Book review
- Kuala Lumpur
- Italy
- erlang
- comic agile
- Linux
Archives
- Today
- Total
Do not use loop for list iterations - lamdaj 본문
2011/04/26 - [Programming/Java] - Do not use loops for list operations
2011/04/28 - [Programming/Java] - Do not use loops for list operations
2011/04/28 - [Programming/Java] - Do not use loops for list operations
import java.util.ArrayList; import java.util.List; import com.google.common.collect.Lists; import ch.lambdaj.Lambda; import static org.hamcrest.Matchers.greaterThan; // item 3 from http://codemonkeyism.com/generation-java-programming-style // -cp .:./Guava/guava-r09/guava-r09.jar:./lambdaj-2.3.2-with-dependencies.jar public class TestFilter { public static void main(final String[] args) { List<Person> persons = Lists.newArrayList( new Person("A", 15), new Person("B", 16), new Person("C", 17)); List<Person> beerDrinkers = // http://code.google.com/p/lambdaj Lambda.select(persons, Lambda.having(Lambda.on(Person.class).getAge(), greaterThan(16))); } } interface HasAge { public int getAge(); } class Person implements HasAge { public final String name; public final int age; public Person(String name, int age) { this.name = name; this.age = age; } public int getAge() { return this.age; } public String toString(){ return name + " = " + age; } }