I wrote a function in Java and I want this function to return multiple values. Except use of array and structure, is there a way to return multiple values?
My code:
String query40 = "SELECT Good_Name,Quantity,Price from Tbl1 where Good_ID="+x;
Cursor c = db.rawQuery(query, null);
if (c!= null && c.moveToFirst())
{
GoodNameShow = c.getString(0);
QuantityShow = c.getLong(1);
GoodUnitPriceShow = c.getLong(2);
return GoodNameShow,QuantityShow ,GoodUnitPriceShow ;
}
In Java, when you want a function to return multiple values, you must
In your case, you clearly need to define a class
Showwhich could have fieldsname,quantityandprice:then change your function to