The requirement is: Storing int type elements in a List, then writing a Helper class with two static methods to sort those int type elements in the List in increasing and decreasing order.
I passed the reference variable "list" to the method increasingSort(line 23), then I got an error: "The method toArray(Integer[]) is undefined for the type List", when I was trying to use the toArray() method(line 31).
I know toArray() method belongs to List, this error is really confused...
Can anyone explain this to me...Thanks a lot!
Moving on is a simple thing, what it leaves behind is hard. You know the sleeping feel no more pain, and the living are scarred. ---A Tout Le Monde by Megadeth
Henry Wong wrote:Hint: Is there a difference between this ...and this ??
Or indeed:Note - no 'static'.
My main worry about your method is that it doesn't actually sort. It simply display the contents of a (presumably) sorted List.
Naming is very important.
Winston
Actually it's just a part of the code and hasn't been finished yet....Thanks for your reply!
Moving on is a simple thing, what it leaves behind is hard. You know the sleeping feel no more pain, and the living are scarred. ---A Tout Le Monde by Megadeth
Volodymyr Levytskyi wrote:toArray method requires its argument to be of type the same as Generic type of List itself. So introduce generic type for argument List list like:
Really appreciating your answer, it's the right solution and I've know what my mistake is....
Moving on is a simple thing, what it leaves behind is hard. You know the sleeping feel no more pain, and the living are scarred. ---A Tout Le Monde by Megadeth
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
a bit of art, as a gift, the permaculture playing cards