Convert int[] to comma-separated string

后端 未结 6 731
情深已故
情深已故 2021-01-12 23:45

How can I convert int[] to comma-separated String in Java?

int[] intArray = {234, 808, 342};

Result I want:

\"         


        
6条回答
  •  抹茶落季
    2021-01-13 00:15

    This should do

    String arrAsStr = Arrays.toString(intArray).replaceAll("\\[|\\]", "");
    

    After Arrays toString, replacing the [] gives you the desired output.

提交回复
热议问题