In my opinion (which is an opinion) the best way would be the way that is the simplest.
That is a biased opinion based on the following assumptions:
- You haven't profiled your code, so it's probably an unknown if this section of code is a performance bottleneck. This means that optimizing it is premature optimization.
- If you do it the simplest way, then you will likely incur the fewest bugs due to "cleverness".
An example follows
List<Float> floats = ...;
List<Integer> integers = new ArrayList<Integer>();
for (Float item : floats) {
integers.add(item.intValue());
}
return integers;
And as many have noted, since you didn't specify what was important, it is hard to know which solution might best satisfy your unspoken requirements.