Reputation: 161
I would like to try and loop through this following byte array:
public byte[] mFFTBytes;
How would I go about doing this in java with a for loop?
Thanks in advance!
Upvotes: 1
Views: 29501
Reputation: 458
First of all you need to instantiate your array because you will have null pointer exceptions all over the place.
Then you can use a for each loop
for(byte b : mFFTBytes){
System.out.println(b);
}
Upvotes: 7
Reputation: 1169
I am not sure if I understand well what you are asking for. Going through any array in Java is quite trivial action like:
for (byte myByte: mFFTBytes) {
//do something with myByte
}
or
for (int i=0;i<mFFTBytes.length;i++) {
//do something with mFFTBytes[i]
}
The latter should be faster, but for a vast majority of applications is does not matter much.
Upvotes: 0