I'm seeking to place a 1 dimensional array inside of a 2d array with java. With the method I call I'm passing the list that I'll be collecting the data from and also the 2d array I want to pass the information to. After creating a set of an string I dissect the sentence by 2 place the characters into shingleSet. From shingleSet I must convert the strings to an array, sort the data then save the sorted array into the 2d array. The problem I'm having is that I can load the array but I can only load it locally. Would I have to return a 2d array from the method?
private static void sentenceToShingles(int n, String[][] stringArray, List list){
int i, j;
String e;
String [] newShingle;
int counter = 0;
stringArray = new String [n][];
for(Object o: list){
//for every sentence create a new hashset
Set<String> shingleSet = new HashSet();
e = (String) o;
i=0;
while((i+2) < e.length()){
for(j=0;j<2;j++){
shingleSet.add(e.substring(i, i+2));
}
i++;
}
//add to array and sort ?RETURNING?
newShingle = shingleSet.toArray(new String[shingleSet.size()]);
Arrays.sort(newShingle);
//?? How can I save newShingle into 2d array??
//print shingle sorted shingle array
for(j=0; j<newShingle.length; j++){
System.out.print(newShingle[j] + " ");
}
System.out.println();
}
System.out.println();
}