Yes - you are creating a completely new List
, containing the elements of the original one. You are duplicating the collection in memory, and iterating it from start to end. You are also not using instance provided by the service, and you can't modify the original. And finally, you've omitted the generics declaration in the 2nd snippet.
So use the first option.
Update: you indicated you are not allowed to modify the original list. This is actually a problem of fooService
, not of its clients. If the service is also in your control, return Collections.unmodifiableList(originalList)
- thus clients won't be able to perform modification operations (on attempt an exception will be thrown)