我已经制作了下面的数组,但没有幸运地将其排序为
String[] albums = {"Abbey Road - Beatles","Thriller - Michael Jackson",
"Queen - News of the World","Gimme Shelter - The Rolling Stones",
"Pink Floyd - The Dark Side of the Moon"};
使用Collections.sort(相册(;给出错误:没有合适的排序方法(String[](
我导入了java.util.*;但是这个错误仍然存在
我仍在学习,不知道如何解决这个问题,也不知道我错过了什么
您有一个数组(而不是Collection
(。你可以用Arrays.sort(T[], Comparator<? super T>)
来排序。比如,
Arrays.sort(albums, Comparator.naturalOrder());