代码如下,为什么要"return temp.substring(0, temp.length() -1 );"而不是temp。还有,string类型不是final 的吗,它还可以变化?
/**
* 将数组转换成字符串,使用","分隔
*/
public static String arr2Str(Object[] value) {
String temp = "" ;
if(ValidateUtil.isValid(value)){
for(Object o : value){
temp = temp + o + ",";
}
return temp.substring(0, temp.length() -1 );
}
return null;
}
/**
* 将数组转换成字符串,使用","分隔
*/
public static String arr2Str(Object[] value) {
String temp = "" ;
if(ValidateUtil.isValid(value)){
for(Object o : value){
temp = temp + o + ",";
}
return temp.substring(0, temp.length() -1 );
}
return null;
}