Hello i need to replace the Nan values with 0 in my array in java, any help thanks. you can find the example of my array.
The array type is double
and the contents of array are as follows.
x = [ 1 , 2, Nan , 4, Nan ]
Loop the array and use isNaN
method from Double
to check if the number is NaN
.
for(int i=0; i<array.length; i++){
if(Double.isNaN(array[i])) {
array[i] = 0d;
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments