Question: Sorry for the title, but I didn't know how to explain it better!

Suppose that I have this class in Java:

```
public class ToyClass {
    public int number;
}

```

And a list of ToyClass objects called `ToyClassList`

There is any way to do something like this:

```
List<Integer> numbersInToyClassList = new ArrayList<>().addAll(ToyClassList.number)

```

In other words I'm trying to writing in a more elegant way this code:

```
List<Integer> numbersInToyClassList = new ArrayList<>();
for(ToyClass element : ToyClassList)
    numbersInToyClassList.add(element.number);

```

Answer: 
In Java 7 and earlier you can add few lines of code to implement your own Stream API:

```
    interface Function<A, B> {
        B map(A a);
    }

    class ListUtil {
        public static <A, B> List<B> map(Function<A, B> function, List<A> aList) {
            List<B> bList = new ArrayList<>();
            for (A a : aList) {
                bList.add(function.map(a));
            }
            return bList;
        }
    }

```

And transform your `toyClassList` with following code:

```
List<Integer> numbersInToyClassList = ListUtil.map(
    new Function<ToyClass, Integer>(){
         public Integer map(ToyClass toy){
             return toy.number;
         }
    }, toyClassList);

```
In Java 8 , you could do

```
List<Integer> numbersInToyClassList = toysClassList.stream()
  .map(ToysClass::getNumber)
  .collect(Collectors.toList);

```

Whether this is more elegant is your judgement.

Btw: your object `numbersInToyClassList` should be in lower camel-case, as it is not a Type.