So the program seems simple enough but for some reason when I compile it in the windows command prompt, I get an error that reads "error, cannot find symbol and it point to the period between the list.add(); Any ideas what I'm doing wrong? Thanks!

//  NOTE:  THERE ARE FOUR  LINES OF CODE TO ADD TO THIS CLASS
// ListTest class to demonstrate List capabilities.

public class ListTest 
{
   public static void main( String args[] )
   {
      List list = new List(); // create the List container

      // insert integers in list
	  //  add code here to insert the following values at the back of the list ( -1  0  1  5  )
	  list.add(-1); // add code here
      list.print();
	  list.add(0);	// add code here
      list.print();
      list.add(1);	//  add code here
      list.print();
      list.add(5);	//  add code here
      list.print();

      // remove objects from list; print after each removal
      try 
      { 
         Object removedObject = list.removeFromFront();
         System.out.printf( "%s removed\n", removedObject );
         list.print();

         removedObject = list.removeFromFront();
         System.out.printf( "%s removed\n", removedObject );
         list.print();

         removedObject = list.removeFromBack();
         System.out.printf( "%s removed\n", removedObject );
         list.print();

         removedObject = list.removeFromBack();
         System.out.printf( "%s removed\n", removedObject );
         list.print();
      } // end try
      catch ( EmptyListException emptyListException ) 
      {
         emptyListException.printStackTrace();
      } // end catch
   } // end main
} // end class ListTest

Which line in you source is the error on?
I don't see the line you mentioned: list.add();
All the calls to add() have arguments, none are empty like you say the error is about???

Which line in you source is the error on?
I don't see the line you mentioned: list.add();
All the calls to add() have arguments, none are empty like you say the error is about???

Lines 12, 14, 16, 18. (Code left of comments that say "add code here") I thought that list.add(int) would add that int to the list but it gives me an error when i try to compile.

Have you read the API doc for the class you are trying to use?
What does it say about how to use the add method?

Have you read the API doc for the class you are trying to use?
What does it say about how to use the add method?

To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'

Paste here.

Edited 4 Years Ago by NormR1: n/a

No I havent read an API. Im just starting to learn Java. but if you would be so kind to post a link to the API doc, I will I'll read through it. And thanks for the posting tip

This article has been dead for over six months. Start a new discussion instead.