• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot resolve a symbol with a method.

 
Brian Walsh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greg Charles
Sheriff
Posts: 2993
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Brian Walsh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic