Java Guava | Doubles.asList() method with Examples
The Doubles.asList() method of Guava’s Doubles Class accepts a double array as a parameter and returns a list which has the fixed size. The returned list is backed by the double array which is passed as the argument. It means the changes made in the array passed as parameter will be reflected back in the list returned by the method and vice-versa.
public static List<Double> asList(double… backingArray)
Parameter: The method accepts a mandatory parameter backingArray which is a double array that is used to back the list.
Return Value: The method Doubles.asList() returns a fixed-size list which is backed by the array passed as the argument to the method. In other words, the method returns the list view of the array.
Below examples illustrate the implementation of above method:
[1.2, 2.3, 3.4, 4.5, 5.6]
[3.2, 5.5, 7.6]