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 (m.sbmmt.com)!