File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes cannot resolve a symbol with a method. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "cannot resolve a symbol with a method. " Watch "cannot resolve a symbol with a method. " New topic
Author

cannot resolve a symbol with a method.

Brian Walsh
Greenhorn

Joined: Feb 06, 2002
Posts: 17
Hi I am having problems with a program in that I am supposed to be sorting some objects with a general objects sort that I was given, and I am now recieving this compile error:

Here is the Program that I having proplems with.

Here is the Sorts program I am working with.

Here is the program that I pulled that line of code from to create an insertion sort...



I just added that last bit for people to look at so they could compare it. I figured too much info is better than too little. Thanks in advance for your help on the matter.


-Thanks in Advance
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2851
    
  11

It seems to me that your Sorts class has two versions of insertionSort(). One takes an array of ints and the other takes an array of Comparable objects. You are trying to pass in a CDCollection. You either need to overload insertionSort() to handle a CDCollection, or get the data from CDCollection into an array of Comparables, and pass that to insertionSort().
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
There are some small, but major, differences between the example and your own program. First of all, the example declares the variable "friends" as an array of Contact objects, but your "music" variable is a single instance of CDCollection, not an array. I suspect that the Contact class extends the Comparabe interface, which allows it to use the coresponding version of insertionSort(). To do something similar, you should probably create a CD class which extends Comparable. Then you just have to create an array of CD objects which you can pass to the Sorts.insertionSort() method.
If CDCollection has such an array already, you may just want to have a CDCollection.sort() method which in turn callsl Sorts.insertionSort().
After that long-winded answer, the main point here is that insertionSort() takes an array as its argument, but you haven't created an array in your program. You can fix this problem with one of the suggestions provided by Greg or myself. Or if you can think of something else, please feel free to use it.
Keep coding!
Layne


Java API Documentation
The Java Tutorial
Brian Walsh
Greenhorn

Joined: Feb 06, 2002
Posts: 17
thanks for the help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot resolve a symbol with a method.