954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

writing a new record problem

hey guys and gals,

newb back again with a little request from the Java Gods. in line 31 i've got an error saying "cannot find symbol"

NextRecord record = new NextRecord();


i've got 2! count 'em 2 Java books and i'm still stuck...Help?

import java.io.File;
import java.io.FileNotFoundException;
import java.lang.IllegalStateException;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class NumberStudy
{
private Scanner input;

//enable user to open file
public void openFile()
{
try
{
input = new Scanner(new File("numbers.txt"));
}// end try
catch (FileNotFoundException fileNotfoundException)
{
System.err.println( "Error opening file.");
System.exit(1);
}//end catch
}// end method openFile

//read record from file
public void nextInt()
{
//object to be written to screen
NextRecord record = new NextRecord();

System.out.printf( "%s%10s", "Rating ", "Frequency ");

try //read from the file using the scanner
{
while (input.hasNext())
{
record.setRating(input.nextInt());
record.setFrequency(input.next());

//display record contents
System.out.printf( "%s%10s", "Rating ", "Frequency ", record.getRating(), record.getFrequency());
} //end while
} // end try

catch(NoSuchElementException elementException)
{
System.err.println( "File imporperly formed.");
input.close();
System.exit(1);
}//end catch
catch (IllegalStateException stateException)
{
System.err.println("Error reading from file.");
System.exit(1);
}//end catch
}//end method nextInt

//close file and terminate application
public void closeFile()
{
if (input != null)
input.close(); //close file
}//end catch
}//end class NumberStudy
leroi green
Junior Poster in Training
93 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

"i've got 2! count 'em 2 Java books and i'm still stuck...Help?"

I've got 200...

Quite obviously (learn to interpret error messages...) the compiler knows nothing about a class "NextRecord".

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

If I understand correctly, you are getting "can not resolve symbol" error on NextRecord...

If that is the case, then you need to "import" the package that contains "NextRecord" class.

new_2_java
Junior Poster
127 posts since Apr 2007
Reputation Points: 7
Solved Threads: 6
 

If I understand correctly, you are getting "can not resolve symbol" error on NextRecord...

If that is the case, then you need to "import" the package that contains "NextRecord" class.


cool, i'll do that now.

leroi green
Junior Poster in Training
93 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You