split into a 2d array
in
Programming Questions
•
1 year ago
Hi, I'm bringing in a string and I'm trying to split it so new vectors can be properly arranged in a arrayList<arrayList<myclass>>myarray, but I am having trouble with the spliting part. What a I have is S number of sets with N number of nodes with 3 coords each. The error so far (god know how many others are there) is "unexpected token:]" on line
sets2d[i][] = split (sets[i], 'n');
any ideas on what am I doing wrong or where to look for the right answer? thanks!
ArrayList<ArrayList<Mover>>movers2d = new ArrayList<ArrayList<Mover>>();
message = new String( data );
String[] sets = split (message, 's');
string[][]sets2d = new string[sets.length][];
for (int i = 0; i<sets.length; i++) {
sets2d[i][] = split (sets[i], 'n'); // here is the error
}
for(int i=0; i<lines.length; i++){
movers2d.add(new ArrayList<Mover>());
for(int j=0; j<lines[i].length; j++){
if (lines[i].startsWith("]")){
float values[] = float(sets2d[i][j].split("]")[1].split( ","));
movers2d.get(i).add( new Mover(new PVector( values[0], values[1], values[2]) ));
}
}
}
1