I´m looking for a solution to remove rows containing null in a 2 Dimensional array. The tricky part here is that i would like to use only for loop and no help from the java.util.Arrays or similar. I found out a method but it works only in some conditions: The null must be not on the first or last row and not more than 2 null muss be present otherwise I get wrong result.
public static String[][] deleteNull(String[][]Table){
int nbLineToDelete=0;
int count=0;
String [][]resizedTable = null;
for (int i=0; i<Table.length;i++){
if (Table[i]==null){
nbLineToDelete=nbLineToDelete+1;}}
while (count< nbLineToDelete){
for (int i=0; i<Table.length-1;i++){
if (Table[i] == null){
resizedTable = new String[Table.length-1][];
for (int index=0; index<i; index++){
resizedTable [index]=Table[index];}
for (int j=i; j<Table.length-1;j++){
resizedTable [j]=Table[j+1];}
Table[i]=resizedTable[i];}
count=count+1;}}
return resizedTable ;
Any suggestions welcome.