• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Always when I use List is for return any data from Data Base, right?

 
André Asantos
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always when I use List is for return any data from Data Base, right?

And why I need many people use ArrayList together?

Look at:


Can I list using many other ways, right? I just heard about that this way of use
as a typed way... is it correct?

bye,
André AS
São Paulo - Brazil
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>();

hth
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
André Asantos wrote:Always when I use List is for return any data from Data Base, right?


It depends on your situation
 
André Asantos
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you...

André AS
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
André Asantos
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
André Asantos wrote:thank you...

you are welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic