I have an array like this
String arr[][] = {{"abc"}, {"bcd"}, {null}}
This is multi dimensional array (single string array with in an array). I want to remove those nulls and want final result as {{"abc"}, {"bcd"}}. This array could be of any size and there can any number of nulls
I tried something like this. I know I can use traditional for loops, but I want to do it using java8 or more efficiently.
String arr1[][] = Arrays.stream(arr)
.filter(str -> (((str != null) && (str.length > 0))))
.toArray(String[][]::new);
String arr1[][], you should writeString[][] arr1instead, for the brackets actually belong to the type, rather than the variable name. The reason it is legal in Java is probably because it is an artifact from C.