I trying to store my already found 2D array into a 1D array for faster processing later. However, I keep getting a nullPointerException when I try to fill the 1D array. What happens is a txt file has the number of rows and colums that we read first to get the row and column amount for doing the 2D array. Then each index reads the next data element on the txt file and stores it at that index until all 50 000 integer values are stored. That WORKS fine.
Now I want to take that 2D array and store all the elements into a 1D array for faster processing later when looking for answers without using an array list or put them in order, which is fine,
int [][] data = null;
int[] arrayCount = null;
for (int row = 0; row < numberOfRows; row++)
{
for (int col = 0; col < numberOfCols; col++)
{
data[row][col] = inputFile.nextInt();
}
}
//Doesn't Work gives me excpetion
data[0][0] = arrayCount[0];
I tried this in for loops but no matter what I get a NullPointerException