Either you can use an if statement to check if the element you are retrieving is null or you have to keep a record of the size of the populated array for your condition of the loop instead of the size of the array.
do you understand what null is? it's the default value for a non-instantiated but declared Object.
since it has no value (yet) you can't call a method on it.
there are two ways to avoid this from happening:
1. add an conditional statement, checking whether or not the element you're trying to work with is null or not (as been suggested earlier)
2. make sure your array doesn't contain any null values.
String myArrray = new String;
for ( int i = 0; i < myArray.length; i++)
myArray[i] = new String("");
off course, this is just a very basic example, but even though all the String-elements of myArray are an empty String (and you can decide on what your default value could/should be in your case), none of them will cause a null pointer exception.
stultuske is giving you good advice, so you should make more effort to follow it rather than wasting his time. Your latest code completely fails to implement the perfectly good solution that he gave you earlier. Re-read his posts and think carefully about what he says..
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.