0

Need to take input from a file as command line argument and put it in an array, but i keep getting .class expected on this line

temp[][] = infile.nextInt();

Here is the whole code so far for reference

import java.util.*;
class Temps
{
    public static void main(String[] args)
    {
        Scanner infile = new Scanner(new file(args[0]));
        
        string month = inFile.nextLine();
        inFile.nextInt();
        for (int row; row < temp.length; row++)
          for (int col; col < temp[0].length; col++)
            if (infile.hasnext())
              temp[][] = infile.nextInt();
     
     
     
     
     }//end of main
}//end of class
2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by BestJewSinceJC
0

nextInt returns an int, you need to store it at some index in your temp array. You didn't specify an index to store it into. temp[0][1] is an index, temp[][] is not.

0

From the looks of those for loops you'll need to store at temp[row][col] or something similar, but as long as you understand the syntax, you can figure it out from there. Mark as solved if you don't have any more ?s

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.