I am trying to convert an Array of Strings into another 2D Array of Strings by using .split(), so that every row of the 2D Array is filled with one of the split parts. The Array i want to split, should be split into 3 parts as followed:
Content of the Array:
[0]= "25-Mar-18", [1]= "20-Dec-18",[2]= "1-Jan-15";
How it should look like in the 2D Array:
row [0] [0]= "25", [1]= "Mar", [2]= "18";
row [1] [0]= "20", [1]= "Dec", [2]= "18";
row [2] [0]= "1", [1]= "Jan", [2]= "15";
You get the point... Here is my Code. And my Question: is it even possible to store the array with.split into a 2D Array?
Code:
String[] string = {"25-Mar-18", "20-Dec-18", "1-Jan-15"};
String[] [] parts;
void draw(){
for(int i=0; i<string.length;i++){
for(int j=0; j<3;j++){
parts[i] [j] = string[i].split("-");
}
}
printArray(parts);
}
Error:
Error: Type mismatch, "java.lang.String[]" does not match with "java.lang.String"