On Mon, Jan 24, 2011 at 2:41 PM, Greg Brown <[email protected]> wrote:
> > main advantage is the ability to assign to List<J> variable. > > Not sure I see the distinction - the same thing applies to > setListData(List<?>). > I was mentioning the getter operator, not setter. The direction of assignment is important. setter's parameter type is sort of lift hand side while getter return type come to right hand side. In this sense, the use of anonymous type in setter argument is less problematic. The advantage over List<Object> is the ability to assigned the ability to just any List<N>. If we use List<Object> we need to copy another object just overcome this issue. If we need to maintain object identity, this approach is not appropriate. Then we will be stuck. > > > if we use List<?> as the return type, this can be done with cast, but if > we use List<Object> as return type, cast cannot be applied also. > > Right, I had forgotten about that. That's why it currently returns List<?>. > Returning List<T> would simply make the cast unnecessary. -- Cheers, calathus
