package Java_project_1;
public class Test{
public static void main(String[] args) {
int[] arr1=null;
System.out.println(toString(arr1));
int[] arr2={10,88,99};
System.out.println(toString(arr2));
}
public static String toString(int[] arr){
if (arr!=null){
StringBuilder sb=new StringBuilder("[");
for (int i=0;i<arr.length;++i){
sb.append(arr[i]).append(i== arr.length-1?"":",");
}
sb.append("]");
return sb.toString();
}else {
return null;
}
}
}
08-25
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-02
1012
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-22
817
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)