How to convert Array content to a String in Java

  • A+

How can the Array content be converted a String in Java?


int[] myArray = {1,2,3}; 

The output has to be:


Arrays.toString(myArray) is returning:

"[1, 2, 3]" 

and myArray.toString(), returns:


So none of them works. Is there a function for this?

This question might look similar to (this), but is actually different. I am really asking for a String made of all the array entries.


String joined =             .mapToObj(String::valueOf)             .collect(Collectors.joining(""));  System.out.println(joined);    


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: