One - One Code All

Blog Content

java中打印数组的5种方法

Java   2013-01-12 22:39:17

Arrays.toString(arr)

----------------------------

for(int n: arr) 

   System.out.println(n+", ");

-----------------------------

for (int i = 0; i < arr.length; i++) {

   System.out.print(arr[i] + ", ");

}

-----------------------------

System.out.println(Arrays.asList(arr));

-----------------------------

Arrays.asList(arr).stream().forEach(s -> System.out.println(s));//java8



上一篇:Spring.properties文件中将元素作为数组获取
下一篇:java时间戳10位和13位以及日期格式化

The minute you think of giving up, think of the reason why you held on so long.