Goal:  

Make a group by for the datamember \_age and then \_amount by using java

The result should be: 

```
age      amount
---------------
  0           8
  1           8
  2           8
  3           8

```

Problem:  

I was not expected that it would be more difficult to do it in java compare to C#

Based on the inspiration from this [page](https://www.mkyong.com/java8/java-8-collectors-groupingby-and-mapping-example/) I was trying to make group by but it didn't work.

What part am I missing

Thank you!

---

```
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class JavaApplication22 
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) 
    {
        List<Test> _Test = new ArrayList<>();
        _Test.add(new Test(0, "df", 4));
        _Test.add(new Test(0, "we", 4));
        _Test.add(new Test(1, "df", 4));
        _Test.add(new Test(1, "we", 4));
        _Test.add(new Test(2, "df", 4));
        _Test.add(new Test(2, "we", 4));
        _Test.add(new Test(3, "df", 4));
        _Test.add(new Test(3, "we", 4));

        // This one below is error
        Map<String, Integer> sum = _Test.stream().collect(Collectors.groupingBy(Test::get, Collectors.summarizingInt(Test::get)));

    }

}

```

---

```
public class Test
{
    private int _age;
    private String _sex;
    private int _amount;

    public Test(int age, String sex, int amount)
    {
        _age = age;
        _sex = sex;
        _amount = amount;
    }

    public int getAge()
    {
        return _age;
    }    

    public String getSex(String sex)
    {
        return _sex;
    }     

    public int getAmount()
    {
        return _amount;
    }    
}

```