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源码+清净的心地。
时间: 2024-10-11 09:06:10