I am trying to get an array that consists 1's and 0's with a length determined after it has been ran. "arr1.length" is taken from user beforehand.
private double[] arrayGen(int A) {
double[] arr1 = new double[A];
for (int i = 0; i < arr1.length; i++) {
arr1[i] = (Math.random());
}
this is what i tried so far, it is generating random "double"s, and I can't make it generate 1's and 0's randomly.
Thank you for your help.
John
Aucun commentaire:
Enregistrer un commentaire