2016-11-24 20:39发布
public static void main(String[] args) { String[] arr = {"a","b","c"}; for(int i = 0; i < arr.length; i++){ System.out.print(arr[i] + ","); }}}输出结果最后多了一个, 怎么改写啊?
for(int i = 0; i < arr.length; i++){
if(i == arr.length-1){
System.out.print(arr[i]);
}else{
System.out.print(arr[i] + ",");
} }
最多设置5个标签!
for(int i = 0; i < arr.length; i++){
if(i == arr.length-1){
System.out.print(arr[i]);
}else{
System.out.print(arr[i] + ",");
}
}
一周热门 更多>