gauravflame
asked on
Return 2 int values
How to return the two integer values in Java terms
int getnumber(int a ,int b)
{
number1 = a;
number2 = b;
//return new int[]{number1,number2};
//return number1 , number2;
}
int getnumber(int a ,int b)
{
number1 = a;
number2 = b;
//return new int[]{number1,number2};
//return number1 , number2;
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>it doesn't mean we are returning the two int arrays , not two integers
It means you're returning two ints in an array
It means you're returning two ints in an array
int[] means returning a single int array containing an unspecified number of ints.
a bean as Bart_Cr suggests is typically the way to go.
using an array is somewhat error prone
using an array is somewhat error prone
>>using an array is somewhat error prone
In what way?
In what way?
ASKER
int[]
it doesn't mean we are returning the two int arrays , not two integers