Java中如何将字符串数组转换成字符串

如果将“字符串数组”转换成“字符串”,只能通过循环,没有其他方法:

public static String getExecSqlString(String str){

  StringBuffer sb = new StringBuffer();

  String prefixStr = str.substring(0,str.indexOf("("));

  String subStr = str.substring(str.indesOf("(")+1,str.substring(")"));

  String vals[] = subStr.split("(");

  for(int i=0;i<vals.length;i++){

    if(i == vals.length-1){

      vals[i] = "?";

    }else{

      if(i == 0){

        vals[i] = "(?,";

      }else{

        vals[i] = "?,";

      }

    }

    sb.append(vals[i]);

  }

  return prefixStr+sb.toString();

}

================END========================  

posted @ 2017-07-22 18:10  夏日树叶  阅读(5176)  评论(0编辑  收藏  举报