I want to output certain values, which I declare in other array, from an array. Now I got something like that:
int [] tab = new int[110];
int [] skip = {3,4,8,9,12,13,16,17,20,21};
for (int i=0; i<110; i++) {
if (i == any_value_of_skip[])
System.out.print(tab[i]+", ");
}
I put 1 and 0
bits into tab[] array
and I want to output those bits, at which index in tab[] array has exact number as in skip[] array.
[edit] tab[] array has 1 and 0, because:
for (int i = 0; i<110; i++) {
Random r = new Random();
tab[i] = r.nextInt(2);
if (i%25==0) {
System.out.println("");
}
System.out.print(tab[i]+"("+i+")"+", ");
}
System.out.println("");
And I want to apply Hamming code here, so I need to output those bits, which indexes in tab[] array has parity, like 1,2,4,8,16,32,64
.
To better describe it, here is tutorial what I use to make a program https://www.youtube.com/watch?v=JAMLuxdHH8o I am at moment, where I want to output bits, which indexes are: 2,3,6,7,10,11,14,15 and so on...
If you want to output the values of the array, in my opinion the simplest method is probably a
for-each
loop:If you wish to print
tab
values (and you have not posted how they are initialized) you might usetab[i]
:Or just use
Arrays.toString(int[])
:Since
tab
is an array of110
zeros, there is not much you would be able to do with it.