java - How to format array in string -
i want format log this:
"order orderid=1,orderid=2,orderid=3,orderid=4"
i have array values [1,2,3,4]
. understand enough easy use loop want know if there tool in jdk (or library) can this.
using java 8:
int[] n = new int[]{1,2,3,4}; string orders = arrays.stream(n).maptoobj(i -> "orderid=" + i).collect(collectors.joining(",")); string result = "order " + orders;
Comments
Post a Comment