How to convert an array to string in java?

The Arrays class of the java.util package provides toString() methods for all primitive data types and object. These methods accept an array and return its string representation.

Therefore, to convert an array to string pass the required array to this method.


Live Demo

import java.util.Arrays;

public class ArrayToString {
   public static void main(String args[]) throws Exception {
      int[] myArray = {23, 93, 56, 92, 39};
      String str = Arrays.toString(myArray);


[23, 93, 56, 92, 39]