So, I'm having some trouble with an array of a class in a project I'm working on.
The class is called choice.
Here's the relevant code:
In variable declarations:
choice[] choices = new choice[9];
in setup() :
for (int i = 0; i < 9; i++) {
choices[i] = new choice(i+1);
}
The class itself:
class choice {
String[] option = new String[4]; //4 options per choice
int[] optionIndex = new int[4];
int workNum = 0, optionType = 0;
choice(int tempNum) {
option[0] = "";
option[1] = "";
option[2] = "";
option[3] = "";
workNum = tempNum;
}
}
(there's a lot more to the class code, but I removed it and still had the same problem so I've left that code out)
That's the only code that references the class.
When I try to run the sketch, I get the following error:
Syntax error, maybe missing a right parenthesis?
expecting RPAREN, found ';'
processing.app.SketchException: Syntax error, maybe a missing right parenthesis?
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:314)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:197)
at processing.mode.java.JavaBuild.build(JavaBuild.java:156)
at processing.mode.java.JavaBuild.build(JavaBuild.java:135)
at processing.mode.java.JavaMode.handleRun(JavaMode.java:176)
at processing.mode.java.JavaEditor$20.run(JavaEditor.java:481)
at java.lang.Thread.run(Thread.java:680)
For the life of me, I can't figure out where it's expecting to find a right parenthesis. I've made the class entirely empty and created only 1 instance (not an array) of it, and I still get the same error. It highlights the final curly bracket of the choice class when it presents the error message.
Through the use of error checkers, I have confirmed that it runs setup() until the for loop I posted, at which point it hits the missing right parenthesis error.
Can anyone help me figure this out? I'd be happy to post more code if you think it is necessary, but I don't know how it would be relevant. It's probably just some silly oversight I'm making.