I'm having trouble with creating an Arraylist
in a new class (I'm using the DrJava IDE). The assignment is to create a constructor with n
lottery tickets numbered from 1 to n
.
import java.util.ArrayList;
public class Tombola {
private ArrayList<Integer> arr;
public Tombola(int n){
for (int i = 0; i < n-1; i++){
this.arr.add(i) = i + 1;
}
}
}
The error I get is:
unexpected type.
required: variable.
found: value.
I've tried to change n
and i
to integer, but it didn't help.