I would like to know how I can separate a string and assign it to a specific row of a 2d array automatically in the same fashion that the single dimensional array is instantiated below:
public class TestArray {
public static void main (String [] args) {
String file1description= "We went to the mall yesterday.";
String[] file1tags;
String delimiter= " ";
file1tags = file1description.split (delimiter);
for (int i = 0; i < file1tags.length; i++) {
System.out.println (file1tags[i]);
}
}
}
If there are any simpler ways please share. As you can tell I am quite a novice, but I am willing to learn. In this example, each word is separated by the delimiter and stored automatically into the "file1tags" array. How can I do this with a 2d array, so that I can call multiple arrays that have this same function? Thanks in advance!