Java trouble with conversion of int to double


        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: error: incompatible types: possible lossy conversion from double to int
         System.out.printf("%6.1f", (double)temperature[dec]);
1 error


When my own deficiencies get in the way, there is always search:

double temperature[dec]



That's true.
As to

I was trying to cast temperature of each item as a double to see if that helped, it did not.

I'm looking it up on stackoverflow, not finding anything atm.


I'm actually such a moron sometimes, I figured it out. I was trying to do a manual loop but I was using a for each loop. What I really needed was:

        for(double dec : temperature) {
         System.out.printf("%6.1f", dec);

Thanks so much for answering!