I have this:
import java.util.Arrays;
import java.util.ArrayList;
public class Test1 {
public static void main(String[] args) {
double[] a = new double[2];
for( double d : Arrays.asList(a))
System.out.println(d);
}
}
Output:
$ javac Test1.java
Test1.java:9: error: incompatible types
for( double d : Arrays.asList(a))
^
required: double
found: double[]
1 error
Why am I getting an error here?
and
What is the meaning of the error? What is it telling me ?
Arrays#asListworks onObjecttypes, as your headline already says. However, you don't needArrays#asListin that case anyways, as you can iterate over the array.for(final double d: a){ System.out.println(d);}?