把数组转换成sql中能使用的字符串

1、数组对象转换成字符串,拼接成符合sql语句的语法

2、代码如下例子

  public static void testString(){
        String[] str=new String[]{"a","b","c","d","e"};
        String acc = null;
        for (int i = 0; i < str.length; i++) {
            
            acc=acc+"'"+str[i]+"'"+",";
            
        }
        acc=acc.substring(4, 23);
        System.out.println("拼接的字符串为:"+acc);
        
    }

3、结果为:

 拼接的字符串为:'a','b','c','d','e'

  

原文地址:https://www.cnblogs.com/xijin-wu/p/5783854.html