Q:

convert array to string java

Given an array of numbers (integers) how would I go about converting it to a string.
I am from JS so in we normally do : 
[1 , 2 , 3 , 4 , 5].join(separator)

But Java doesn't seem to do that. 
I tried : 
 array.join(" ")

But that throws an error on that it cannot find symbol. 

Here is the code : 
class Conv {
    public static String findOut(int[] arr) {
        return arr.join(" ");
    }
}

A:

Arrays#toString
Java does not provide a join method for arrays. Utility methods can be found in the Arrays class. For example Arrays.toString(values) (documentation) which returns a String in the following format:
[1, 5, 15, 2]

So
String result = Arrays.toString(values);

StringJoiner
However, you explicitly want the following format:
1 5 15 2

Therefore, use the StringJoiner class (documentation):
StringJoiner sj = new StringJoiner(" ");
for (int value : values) {
    sj.add(value);
}
String result = sj.toString();

Stream API
Or use the Stream API (documentation) to achieve the same result but in a more functional-style:
String result = Arrays.stream(values)  // IntStream
    .mapToObj(Integer::toString)       // Stream<String>
    .collect(Collectors.joining(" ");  // String

A:

There's no join method on arrays, instead you can use the stream API's joining collector:
Arrays.stream(arr)
      .mapToObj(Integer::toString)
      .collect(Collectors.joining(" "));

