如果要打印一个数组的内容,就需要通过for循环来挨个遍历,逐一打印
但是Arrays提供了一个toString()方法,直接把一个数组,转换为字符串,这样方便观察数组的内容
import java.util.Arrays;
public class HelloWorld {
public static void main(String[] args) {
int a[] = new int[] { 18, 62, 68, 82, 65, 9 };
String content = Arrays.toString(a);
System.out.println(content);
}
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...