I have a string array which is filled with numbers. Any unset element in the array will be null by default. I'm then looping through this array, parsing the Strings to their int values, but I'm running into a NumberFormatException when the loop reaches a null element.
I don't know in advance how many numbers will be in the array, so I'm using a large array to make sure there is enough space to hold all of the Strings.
How can I stop the loop before it reaches a null element?
for (int x = 1 ; x < array1.length ; x++){
int newnode = Integer.parseInt(array1[x]);
//searching in matrix
// do other stuff
}