Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Returning different objects from a result set

 
Stephen Murray
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am doing an application which requires me to return an Integer and Long value obtained from a result set in a method. As these are different types and cannot be used in an array can someone please advise me on how to access these values in the calling method, thanks.
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Who says they can't be in an array? They are both subclasses of Object, after all.

But it's usually better to create a class to represent a row of a ResultSet. In your case the class would have two attributes which are int and long values.
 
Stephen Murray
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Who says they can't be in an array? They are both subclasses of Object, after all.

But it's usually better to create a class to represent a row of a ResultSet. In your case the class would have two attributes which are int and long values.


What type of arrays can store more than one type? I have been looking (a lot) and did not come across one.
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Object arrays can store any type of object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic