I am currently developing an android project using eclipse JAVA and I had just written the method below,
ArrayList<string> question, modelAnswer, correctAnswer, answer1, answer2, answer3, picture, questionNo;
public void QuestionGenerator(String[][] array, int number ){
if (number > array.length){
number = array.length;
}
Collections.shuffle(Arrays.asList(array));
for (int i=0; i<number; i++){
question.add(array[i][0]);
modelAnswer.add(array[i][1]);
answer1.add(array[i][1]);
answer2.add(array[i][2]);
answer3.add(array[i][3]);
picture.add(array[i][4]);
questionNo.add(array[i][5]);
}
}
But I am having the error of “The method add(R.string) in the type ArrayList is not applicable for the arguments (String)” coming up for the add function for those array lists. Could anyone suggest me why I got this? Is the method can’t handle with 2d array or why?
Thanks
Try to use the uppercase String 🙂
And initialize the ArrayLists: