i have one String[]
String[] name = {\"amit\", \"rahul\", \"surya\"};
i want to send name as parameter in sql query inside IN
As tempting and "cool" as the code may appear, do not use fold or reduce on large collections of strings, as these will suffer from the string concatenation problem
String[] strings = { "foo", "bar", "baz" };
Optional result = Arrays.stream(strings)
.reduce((a, b) -> String.format("%s,%s", a, b));
System.out.println(result.get());
Instead, as per other answers, use String.join() if you already have a collection, or a StringBuilder if not.