Home  >  Article  >  Java  >  Java Example - Array Output

Java Example - Array Output

黄舟
黄舟Original
2017-02-18 10:06:011180browse

The following example demonstrates how to output an array through a loop:

/*
 author by w3cschool.cc
 文件名:Main.java
 */public class Welcome {
   public static void main(String[] args){
      String[] greeting = new String[3];
      greeting[0] = "This is the greeting";
      greeting[1] = "for all the readers from";
      greeting[2] = "Java Source .";
      for (int i = 0; i < greeting.length; i++){
         System.out.println(greeting[i]);
      }
   }}

The output result of the above code is:

This is the greeting
For all the readers From
Java source .

The above is the Java example - the content of the array output, For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn