It is homework question.
Question:
“Use an array of integers with size 10 and print the content of the array using write( ) method.
Note: Please do not use System.out.println( ) method.”
This is what I have tried so far, but it doesn’t work.
int i = 0;
while (i != array.length) {
byte[] temp = new byte[4];
temp[0] = (byte) (array[i] & 256);
array[i] = array[i] >> 8;
temp[1] = (byte) (array[i] & 256);
array[i] = array[i] >> 8;
temp[2] = (byte) (array[i] & 256);
array[i] = array[i] >> 8;
temp[3] = (byte) (array[i] & 256);
System.out.write(temp, 0, 4);
i++;
}
I can’t find a way to do this, please help me out.
Thanks in advance. 🙂
Edit: prettier: