标签:pac append system stringbu nbsp arrays pen pre ase
os :windows7 x64
jdk:jdk-8u131-windows-x64
ide:Eclipse Oxygen Release (4.7.0)
code:
package jizuiku2; import java.util.Arrays; public class Demo100 { public static void main(String[] args) { String str = Arrays.toString(new int[] { 1, 2, 3, 4, 5 }); System.out.println(str); } }
result:
scoureCode:
public static String toString(int[] a) { if (a == null) return "null"; int iMax = a.length - 1; if (iMax == -1) return "[]"; StringBuilder b = new StringBuilder(); b.append(‘[‘); for (int i = 0; ; i++) { b.append(a[i]); if (i == iMax) return b.append(‘]‘).toString(); b.append(", "); } }
Java优秀,值得学习。
学习资源:API手册+Java源码+清净的心地。
JavaSE8基础 Arrays.toString 将一维int数组转成字符串输出
标签:pac append system stringbu nbsp arrays pen pre ase
原文地址:http://www.cnblogs.com/jizuiku/p/7469244.html