Arrays.toString(double[]) in Java

Arrays.toString(double[]): This method is available in java.util.Arrays class of Java,

Syntax:

String java.util.Arrays.toString(double[] a)

This method takes one argument of type double array as its parameter. This method returns a string representation of the contents of the specified array.

Parameters: One parameter is required for this method.

a: the array whose string representation to return.

Returns: a string representation of a.

Exceptions: NA

Approach

Java

import java.util.Arrays;

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

        double a[] = { 1, 2, 3, 4 };

        System.out.println(Arrays.toString(a));
    }
}

Output:

[1.0, 2.0, 3.0, 4.0]


No comments:

Post a Comment