Any idea how to perform a trim operation on a 2d array of strings e.g. 3x3 using Java stream API and collect one back to same dimension 3x3 array?
The point is to avoid using explicit for loops.
The current solution would be simply to do a for loop like:
String arr[][] = {
{" word ", " word "},
{" word ", " word "},
{" word ", " word "}};
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
arr[i][j] = arr[i][j].trim();
}
}