Looping through Group on Lambdaj

Posted: March 8, 2013 in web

...

List<Person> persons = new ArrayList<Person>(Arrays.asList(new Person("c", 1, "one"),

new Person("b", 2, "one"), new Person("a", 1, "two")));

Group<Person> groups = group(persons, by(on(Person.class).getAge()));
 for (String key : groups.keySet()) {
 System.out.println(key);
 List<Person> l = groups.find(key);
 for (Person p : l) {
 System.out.println(p.getName());
 }
 }

...

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s