6

【java】不用循环语句如何输入打印数组元素 | iTimeTraveler

 3 years ago
source link: https://itimetraveler.github.io/2015/12/09/%E3%80%90Java%E3%80%91%E4%B8%8D%E7%94%A8%E5%BE%AA%E7%8E%AF%E8%AF%AD%E5%8F%A5%E5%A6%82%E4%BD%95%E8%BE%93%E5%85%A5%E6%89%93%E5%8D%B0%E6%95%B0%E7%BB%84%E5%85%83%E7%B4%A0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

【Java】不用循环语句如何输入打印数组元素

Java中可以使用Arrays.toString()来输出数组,免了使用各种循环来挨个print的痛苦。

package javacc.test;
import java.util.Arrays;

public class Test {
public static void main(String[] args) {
int[] array = {0,1,4,7,2,5,8,3,6,9};
System.out.println(Arrays.toString(array)); //注意这里的 Arrays.toString()
}
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK