Java Arrays.fill(byte[] a, byte val)
Syntax
Arrays.fill(byte[] a, byte val) has the following syntax.
public static void fill(byte[] a, byte val)
Example
In the following code shows how to use Arrays.fill(byte[] a, byte val) method.
/* ww w .j a v a 2 s .co m*/
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// initializing byte array
byte arr[] = new byte[] {1, 6, 3};
System.out.println(Arrays.toString(arr));
// using fill for placing 8
// converting int to byte
Arrays.fill(arr,(byte)8);
System.out.println(Arrays.toString(arr));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »