集册 Java实例教程 将数组的元素初始化为默认值零。

将数组的元素初始化为默认值零。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

524
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将数组的元素初始化为默认值零。

public class Main 

{// 来 自 时 代 J a v a 公 众 号 - N o w J a v  a . c o m

   public static void main(String[] args)

   {

      // declare variable array and initialize it with an array object  

      int[] array = new int[10]; // new creates the array object 


      System.out.printf("%s%8s%n", "Index", "Value"); // column headings

   

      // output each array element's value 

      for (int co
展开阅读全文