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

Recommended Answers

All 3 Replies

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.

got it figure out thanks store as temp[4][7]

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.