this is what I have atm:
I tried to convert the integers form the list to an int array. Problem is that the output is wrong. Logic is: last index from the array -> if 0 break else 2^index.
import java.util.Arrays;
import java.util.List;
public class BinaryArrayToNumber {
public static int ConvertBinaryArrayToInt(List<Integer> binary) {
int x = 0;
int[] binaries = new int[binary.size()];
binary.forEach(integer -> {
Arrays.fill(binaries, integer);
});
for (int j = binaries.length - 1; j>=0; j--) {
if (binaries[j] == 0) break;
else {
x = (int) (x + Math.pow(2, j));
}
}
return x;
}
}