return more than one value from a method


We can't return more than one values from a method.

An alternative way would be, add all those values to be returned into  Array and return that array.

Ex: public int[] returnArray ()
{
int[] myArray=new int[3];
myArray[0] = value1;
myArray[1] = value2;
myArray[2] = value3;

      return myArray;
}

No comments:

Post a Comment