I guess an other way to ask the same question is how to know the number of null pointing elements in an array?
int[] arrayOfEffectiveSizeTen = new int[10];
// some black box in which the content of the array is changed
calculateAverage(arrayOfEffectiveSizeTen) //how can you do this for instance?
Do you really have to do something like this in a for
loop with i < arrayOfEffectiveSizeTen.length
?
arrayOfEffectiveSizeTen[i] == null ? nullPointingElement++ : elementInArray++;
I couldn't find any duplicate question. Which I found weird. In my particular case it's about Java.