I got a nullPointerExceptio on this line:
println("records[0].goals.length "+records[0].goals.length);//NullPointerException
goals does get created but is the data not stored or something?
the data can be vieuwed/ downloaded here:
http://doekewartena.nl/files/temp/data_voetbal3.txt
Code:
Record[] records;
int recordCount;
void setup() {
size(200, 200);
String[] lines = loadStrings("data_voetbal3.txt");
records = new Record[lines.length];
for (int i = 0; i < lines.length; i++) {
String[] pieces = split(lines[i], '\t'); // Load data into array
if (pieces.length == 33) {
records[recordCount] = new Record(pieces);
recordCount++;
}
}
println("records[0].land "+records[0].land);//IT
println("records[0].goals "+records[0].goals);//null
println("records[0].goals.length "+records[0].goals.length);//NullPointerException
}
void draw(){
background(255);
}
class Record {
String land;
int goals[];
public Record(String[] pieces) {
land = pieces[0];
int goals[] = {
int(pieces[3]), int(pieces[5]), int(pieces[7]), int(pieces[9]), int(pieces[14]), int(pieces[16]), int(pieces[18]), int(pieces[20]), int(pieces[25]), int(pieces[27]), int(pieces[29]), int(pieces[31]) };
}
}