Reputation:
import java.util.*;
import java.io.*;
public class ReadPets
{
public static void main (String[] args)
{
ArrayList <Pet> petList = new ArrayList <Pet>;
Scanner inFile = null;
String name;
Pet p;
try
{
inFile = new Scanner
(new FileInputStream ("pets.txt"));
}
catch(FileNotFoundException e)
{
System.out.println("problem opening file.");
System.exit(0);
}
while (inFile.hasNextLine())
{
name = inFile.NextLine();
p = newPet(name);
petList.add(p);
}
inFile.close();
}
}
1 error found:
File: C:\Users\remixt\Desktop\java\ReadPets.java [line: 9] Error: Syntax error on token(s), misplaced construct(s)
I keep getting that error, no idea how to fix it. Also i get the error The constructor Pet(java.lang.String) is undefined
Upvotes: 0
Views: 1057
Reputation: 887365
You forgot the parentheses in your constructor call (new ArrayList<Pet>
)
Upvotes: 0