# The Java Embedded Aggregator Classes FirstAggregate and LastAggregate

FirstAggregate implements the first group element aggregate and LastAggregate implements the last group element aggregate.

### For an overview see page Java Aggregator Class

### Class Definitions

        public static class FirstAggregate implements Aggregate
        {
            public void initialize(Object val)
            {
                first = val;
            }

            public void accumulate(Object val)
            {
            }

            public Object result()
            {
                return first;
            }

            public void merge(Aggregate other)
            {
            }

            Object first;
        }

## LastAggregate

        public static class LastAggregate implements Aggregate
        {
            public void initialize(Object val)
            {
                last = val;
            }

            public void accumulate(Object val)
            {
                last = val;
            }

            public Object result()
            {
                return last;
            }

            public void merge(Aggregate other)
            {
                last = ((LastAggregate)other).last;
            }

            Object last;
        }