you are right. always use Interface to a Type assignment. so that you wont dependent[tiedup] to a particular implementation of the List. i.e, later you want to change to LinkedList implementation, then only List<Name> names new = ArrayList<Name>(); will change to List<Name> names new = LinkedList<Name>();
André Asantos wrote:Always when I use List is for return any data from Data Base, right?
Depends on if you're getting more than one--that kind of detail should be handled in a lower layer than the client code. For example, if I want to select a user by id I wouldn't want a list back, I'd want a user. But if I wanted all users whose first name starts with "A" I'd want a list, even if there might be none or only one.