• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using one function how to return three different string values  RSS feed

 
lalith kumar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends,


I got a problem like using one function i need to return three different string values from the database using java.

Thanks in advance

Lalith
 
Rory Marquis
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create an object that stores them.

you *could* return an array, but personally I would consider this a bit of a horrid way to do it.

Object with 3 string attributes and getters is the way to go IMO.

HTH
Ror
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can:
  • encapsulate these three String values in an object of your own and return that
  • Retrun them as some sort of Collection
  • Return them as an array

  • Pick whichever suits you best.

    (NB: this is not an advanced questions. Please CarefullyChooseOneForum in future )
     
    Ilja Preuss
    author
    Sheriff
    Posts: 14112
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Rory Marquis:

    you *could* return an array, but personally I would consider this a bit of a horrid way to do it.

    Object with 3 string attributes and getters is the way to go IMO.


    Depends on what those three sting values are. In general, I'd agree, though.
     
    Rory Marquis
    Ranch Hand
    Posts: 48
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes you are both right, you need to choose the right option for what you need.

    I suggested the object option as it encapsulates your data and means you don't need to iterate though an array or Collection, and of course is an OO approach
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!