for(double dec : temperature) {
System.out.printf("%6.1f", temperature[dec]);
}
I’m learning for: each loops in Java. Having trouble with this particular line. I have defined the array temperature already as:
double [] temperature = new double[length];
It’s reading in from a file of decimals with 1 number after the decimal point. Why is my code not working? I am not converting from a double to an int, but my error message is as follows:
HeatIndex.java:110: error: incompatible types: possible lossy conversion from double to int
System.out.printf("%6.1f", (double)temperature[dec]);
^
1 error