報(bào)這個(gè)錯(cuò)誤non-static method cannot be referenced冠骄,是因?yàn)槟鉵ame的聲明變量是Object,它并沒有實(shí)現(xiàn)Comparable接口博投,你可以換成Long,或者String試試绸贡,它們都實(shí)現(xiàn)了
Java8 Stream()引發(fā)的“non-static method cannot be referenced from a static context”問題描述:使用Java8 Stream對(duì)數(shù)組進(jìn)行排序 其中sorted()函數(shù)需要傳入一個(gè)Comparator,而我們使用了Comparator中的靜態(tài)方法comparing...