Forums Register Login

Using one function how to return three different string values

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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 )
    +Pie Number of slices to send: Send
     

    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.
    +Pie Number of slices to send: Send
    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
    Trust God, but always tether your camel... to this tiny ad.
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 844 times.
    Similar Threads
    Selection of Origin , destination or both
    if cases and function call
    char* equivalent of JNI?
    build function that return different types based on param
    Recursive problem - I need an idea.
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 28, 2024 12:18:26.