I have a program that displays lyrics on screen. Each line of lyrics is stored in an array. Now from this, I want to create a 2d array with just the individuals words organized in lines like this:
String[] lyrics = {"Line number one", "Line number two"};
String[][] words = {{"Line","number","one"},{"Line", "number", "two"}};
I thought it would just be a simple double for loop that just takes current string, gets rid of spaces, and stores words in array. When I try this however, I get a type mismatch.
public static void createWordArray() {
for(int i=0; i<=lyrics.length; i++) {
for(int j =0; j<=lyrics[i].length(); i++) {
words[i][j] = lyrics[i].split("\\s+");
}
}

splitis an array itself, so it would even be simpler than double for loop :)