problem with storing the returned values in an array
hi, i want to store every returned value from the methods mentioned below in an array "array", but the problem is, there is one method
returns an array. please guide me
Code:
package ProjectTest;
import java.util.Random;
public class GenerateRandomQues {
public void randomise(Group [][]group, int level)
{
Random rand = new Random();
int randIndex = rand.nextInt(3);
int[] array = new int[5];
//
group[randIndex][level].getGroupIndex();// 1
group[randIndex][level].getGroupDiff();// 2
group[randIndex][level].getGroupQues();// 3
group[randIndex][level].getGroupOptions();// 4 this method returns array of options options[]
group[randIndex][level].getGroupAnswer();// 5
}
}
Re: problem with storing the returned values in an array
If the method returns an array you cannot store it as an element of an array of int. Only int values can be stored in an array of int.
You might think about:
* Storing the returned things in an array of something else, like Object. Which is yukky because the whole point of declaring an array to have elements of some specific type is that it will have elements of a specific type.
* Don't store the returned values in an array, instead store them in an instance of some class you define to hold index, diff, question, options and answer. Without knowing anything else this would be my preferred approach.
* Have helper methods that will translate between an array of options and an int. Tricky and only possible if the number of possible arrays of options is rather limited.