Sponsored Link •
|
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:
The proximate cause of the error is found by looking at where aPaperList is declared. Evidently the compiler can't see the declaration--is it maybe out of scope? But it looks like there may be a larger problem. You seem to be mixing up the concepts of an array of objects and the class that encapsulates that array. It is fine (and a good design choice) to create a class called PaperList that contains inside of it a bunch of Paper objects. And if you choose to implement the storage mechanism inside of that class via an array, that also is fine. But that array should be of Papers, not PaperLists. PaperList is the class that contains the array of Papers. Something like this: class PaperList > 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) > 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
|