Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • 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 Windows XP Java
  • 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
 
Author
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 Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

André Asantos wrote:thank you...


you are welcome
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic