java知识点

1、实现list集合逆序排列

Collections.reverse(list);

2、将数组转化为String

StringBuilder sb = new StringBuilder();
String[] str = {“a”,”b”,”c”,”d”,”e”};
for (int i = 0; i < str.length; i++) {
sb.append(str[i]+”/”);
}
return sb.toString();

3、将list转化为String,每个元素用“/”隔开,去除最后的“/”

StringBuilder sb = new StringBuilder();
for (int j = 0; j < list.size(); j++) {
sb.append(list.get(j)+”/”);
}

return sb.toString().substring(0, sb.length()-1);

你可能感兴趣的:(java,String,list)