File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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

cannot resolve a symbol with a method.

Brian Walsh

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

Joined: Oct 01, 2001
Posts: 2963

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!

Java API Documentation
The Java Tutorial
Brian Walsh

Joined: Feb 06, 2002
Posts: 17
thanks for the help.
I agree. Here's the link:
subject: cannot resolve a symbol with a method.
It's not a secret anymore!