Array fill
•
Java
import java.util.*; public class array_fill { public static void main(String[] args) { int array[]=new int[6]; Arrays.fill(array,100); printArray(array); Arrays.fill(array,2,6,50); printArray(array); } public static void printArray(int array[]){ for(int i=0;i<array.length;i++){ if(i!=0){ System.out.print(","); } System.out.print(array[i]); } System.out.println(); } }
The output result is:
100,100,100 100,50,50
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码