int[] arr = {1,2,3};
for(int i=0;i<arr.length();i++){
String temp = "[";
if(temp==arr.length()-1){
temp = temp+arr[i]+"]"
}else{
temp = temp+arr[i]+", "
}
//如果将上面的判断换成正则表达式的话
//temp = temp+((i==arr.length()?arr[i]+"]":arr[i]+", "));
}
System.oout.println(temp);