Working on a project where I have to use a 2D array to store highest and lowest temperatures for each month of the year.
Trying to get the first bit of it to compile but I keep getting these errors:
Line 33: variable high might not have been initialized
for (int high; high < array.length; high++)
Line 35: variable low might not have been initialized
for (int low; low < array.length; low++)
Seems like a simple error, but I just can't figure it out..
here is the code:
import java.util.*; public class HighestAndLowestTemperature { static Scanner console = new Scanner(System.in); static int array; static int high; static int low; static int index; public static void main(String[] args) { System.out.println ("Enter the highest temperature for each month of the year: "); high = console.nextInt(); System.out.println("Enter the lowest temperature for each month of the year: "); low = console.nextInt(); int[][] array = new int[high][low]; } public static void getData(int array[][]) { for (int high; high < array.length; high++) { for (int low; low < array.length; low++) System.out.print(array[high][low] + " "); } } }
Thanks!