報這個錯誤non-static method cannot be referenced房蝉,是因為你name的聲明變量是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對數(shù)組進(jìn)行排序 其中sorted()函數(shù)需要傳入一個Comparator搭幻,而我們使用了Comparator中的靜態(tài)方法comparing...