Java 实例 - 数组填充
Java 教程
· 2019-02-10 11:41:50
以下实例我们通过 Java Util 类的 Arrays.fill(arrayname,value) 方法和Arrays.fill(arrayname ,starting index ,ending index ,value) 方法向数组中填充元素:
Main.java 文件
import java.util.*;
public class FillTest {
public static void main(String args[]) {
int array[] = new int[6];
Arrays.fill(array, 100);
for (int i=0, n=array.length; i < n; i++) {
System.out.println(array[i]);
}
System.out.println();
Arrays.fill(array, 3, 6, 50);
for (int i=0, n=array.length; i< n; i++) {
System.out.println(array[i]);
}
}
}
以上代码运行输出结果为:
100 100 100 100 100 100 100 100 100 50 50 50
点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html
Mastering Bitcoin
Andreas M. Antonopoulos / O'Reilly Media / 2014-12-20 / USD 34.99
Mastering Bitcoin tells you everything you need to know about joining one of the most exciting revolutions since the invention of the web: digital money. Bitcoin is the first successful digital curren......一起来看看 《Mastering Bitcoin》 这本书的介绍吧!