News for hackers. Stuff that matters.
Re:Why I absolutely love java by julian37 on Tuesday February 08, 2011 @08:00PM (#2195690)
This can be a lot shorter using Google Guava [1]:

        Collections2.filter(
                Lists.newArrayList(1, 2, 3, 4),
                new Predicate<Integer>() {
                    public boolean apply(Integer i) {
                        return i % 2 == 0;
                    }
                });
As I understand it, JDK 8 will support lambdas which will make it shorter still.

[1] http://code.google.com/p/guava-libraries/

Re:Why I absolutely love java by shikyo on Tuesday February 08, 2011 @08:29PM (#2195798)
Or with http://code.google.com/p/totallylazy/ (ignoring imports):

sequence(1,2,3,4).filter(even());

Re:Why I absolutely love java by democracy on Tuesday February 08, 2011 @08:20PM (#2195765)
Or apache collections:

		CollectionUtils.filter(new ArrayList(Arrays.asList(1, 2, 3, 4)), new Predicate()
		{
			public boolean evaluate(Object v)
			{
				return ((Integer) v).intValue() % 2 == 0;
			}
		});