The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

adding instantiations to an array

Posted by Keith Bell on February 13, 2002 at 6:20 PM

Hello everyone. Advice on this would be gratefully helpful

I have created a class called Paper (that includes various parameters such as author, title, date, etc)

This class consists of multiple set and get methods and has a constructor to intialise the parameters at the beginning. In the main method at the end I have created an instantiation of the Paper class and wish to add this to an array of Paper objects called Paperlist declared in another class.

In my paperlist array I have created and declared the array and put in a method to add a Paper object to the array as follows :

public void addPaper(Paper aPaper)
{
aPaperList [theNextFreeLocation] = aPaper;
theNextFreeLocation ++;
}

when i call the method to add the instantiation at the end of my my main method with the command

aPaperList.addPaper(p1);

I get a compiler error called variable aPaperList cannot resolve symbol. Any ideas?



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us