I have Boolean Array and I want to change them to double array. If a position is true,then double be 1, else set equal to 0. how can I do that?
my Boolean array:
Boolean [] a = new Boolean [10];
int i = 2;
for(int x = 1; x < 7; x=x+i){
String name = "b" + String.valueOf(x);
a [x] = shared.getBoolean(name, false);}
my double array:
double [] r = new double[10];
You can use a for-loop to fill the double-Array again:
As you see, I'm checking if Boolean a[i] != null, too. This is because you are using the Wrapper-Class Boolean (with capitalized B) of the datatype boolean. In this case, a[i] could be null! So you should check this somewhere to avoid Exceptions.