方法一:直接使用StringBuffer进行转换,简单易懂
public String arrayToString() {
List<Character> result = new ArrayList<Character>();
('a');
('b'); //['a', 'b']
StringBuffer resultStr = new StringBuffer();// 利用StringBuffer将arraylist转为string
for (int i = 0; i < (); i++) {
((i));
}
return ();
}
方法二:使用包下的StringUtils类的join方法,面试中不推荐使用
public String arrayToString() {
List<Character> result = new ArrayList<Character>();
('a');
('b'); //['a', 'b']
String resultStr = (result, ",");
return resultStr;
}