Integer array conversion in String

1

I am a beginner in Java and would like to learn how to convert an array of integers to a String.

    
asked by anonymous 24.06.2014 / 05:50

1 answer

5

To convert an array of type int to a string you should use the #

  

Returns the string representation of the contents of the specified array.

What translated:

  

Returns a string representation of the contents of the specified array.

Example:

Demonstration at ideone.com

import java.util.Arrays;

public class Main {
    public static void main(final String[] args) {

        final int[] matriz = new int[] { 1, 2, 3 };
        System.out.println(Arrays.toString(matriz));
    }
}

Result:

[1, 2, 3]
    
24.06.2014 / 11:20