Fill () Method use reference
Examples of declarations:
Public Static void Fill (intint
Parameters:
a--Array
form--Replace start position (included)
to--Replace end position (not included)
var--the value to replace
Use a reference instance:
Public classTest { Public Static voidMain (string[] args) {int[] A =New int[]{1,2,3,4,5,6}; System.out.println (Arrays.tostring (a)); //{1,2,3,4,5,6}Arrays.fill (A,0); System.out.println (Arrays.tostring (a)); //{0,0,0,0,0,0} int[] B =New int[]{1,2,3,4,5,6}; Arrays.fill (b,2, 4, 0); System.out.println (arrays.tostring (b)); //{1,2,0,0,5,6}boolean[] C= {true,false}; System.out.println (Arrays.tostring (c)); //{True,false}Arrays.fill (c,false); System.out.println (Arrays.tostring (c)); //{False,false}Arrays.fill (c, 0, 1,true); System.out.println (Arrays.tostring (c)); //{True,false}string[] D= {"A", "B", "C", "D", "E", "F"}; System.out.println (arrays.tostring (d)); //{a,b,c,d,e,f}Arrays.fill (d, 1, 2, "HelloWorld")); System.out.println (arrays.tostring (d)); //{a,helloworld,c,d,e,f} }}
Java-arrays class-fill () method detailed