我有这个代码来连接一些数组元素:
StringBuilder sb = new StringBuilder(); private RatedMessage joinMessage(int step,boolean isresult) { sb.delete(0,sb.length()); RatedMessage rm; for (int i = 0; i <= step; i++) { if (mStack[i] == null) continue; rm = mStack[i].getCurrentMsg();// msg is built upfront,this just returns,it's a getter method call if (rm == null || rm.msg.length() == 0) continue; if (sb.length() != 0) { sb.append(","); } sb.append(rm.msg); } rm.msg=sb.toString(); return rm; }
重要的是阵列最多可容纳10个项目,所以它并不多.