So this is his code:
public void parseAll() {
String[] opis = new String[this.d];
Integer[] velikost = new Integer[this.d];
Integer[] poraba = new Integer[this.d];
Trio singleResult;
for (int i = 0; i < this.d; i++) {
singleResult = parseLine(this.dekl[i]);
opis[i] = singleResult.enOpis;
velikost[i] = singleResult.enaVelikost;
poraba[i] = singleResult.enaPoraba;
}
this.opis = opis;
this.velikost = velikost;
this.poraba = poraba;
}
public Trio parseLine(String line) {
Trio ret = new Trio();
Trio oth;
String[] token = line.split("\\s+");
if ("prim".equals(token[0])) {
ret.enaVelikost = new Integer(token[1]);
ret.enOpis = "prim" + ret.enaVelikost.toString();
ret.enaPoraba = (ret.enaVelikost.intValue() / this.b) * this.b;
if (ret.enaVelikost.intValue() % this.b > 0)
ret.enaPoraba = new Integer(ret.enaPoraba.intValue() + this.b);
ret.tokensUsed = new Integer(2);
} else { // the rest of the code not in question
It says the error is in the following lines:
ret.enaVelikost = new Integer(token[1]);
singleResult = parseLine(this.dekl[i]);
Now he went out of his way for this and i am having difficulty reading and understanding the problem. This is a program for translating into a made-up programming language and the error happens when i try to input the following:
8 // this number does nothing in this part of the program
1 // this is a number of lines with declaration of data types
prim 3 // prim stands for primitive type and the 3 is the size of it
3 // this here is the number of commands i want to run
1 1 // these are the commands, the first number is the command number and the second one is for the line i want to run the command in
2 1
3 1
The input works until i hit enter after the second command (2 1), then the error appears. this is the exact error message : java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
I honestly have no clue as to why it would give an error. Any help is apreciated.