Why can’t I make a 2D array with processing?

At school, I am challenging the task of creating a quiz app with the conditions of using .txt files, class syntax, and 2D arrays.

The contents of the .txt file are specified. I haven't been able to handle the data in the .txt file well. Can somebody tell me how to make a 2D array?

questionnaire.txt

questionA?,2,optionsA-1,optionsA-2,optionsA-3,optionsA-4
questionB?,3,optionsB-1,optionsB-2,optionsB-3,optionsB-4
questionC?,4,optionsC-1,optionsC-2,optionsC-3,optionsC-4

questionnaire.pde

String lines[];

String lin;
int ln;
String[] word;

void setup() {
  size(500, 500);
  background(255);

  ln=0;
  lines = loadStrings("questionnaire.txt");
}


void draw() {
  lin =lines[ln];
  word = split(lin, ',');
   println(word[0]); 
   //questionA?
   //questionB?
   //questionC?
  ln++;
  if (ln == lines.length) noLoop();
}

I want to make a 2D array like below.

println(co[0][0]); //questionA?
println(co[0][1]); //2



Read more here: https://stackoverflow.com/questions/68463057/why-cant-i-make-a-2d-array-with-processing

Content Attribution

This content was originally published by y2UcDgAL at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: