MyClass.java:9: error: cannot find symbol
cats.sort((var a, var b)-> -a.compareTo(b));
^
//generic method parameter type set as Comparable otherwise compilation error
Comparator<Comparable> c = (a, b) -> -a.compareTo(b);
or
Comparator<String> c = (a, b) -> -a.compareTo(b);
or
Comparator c = (a, b) -> 0; //here missed generic method parameter type
int i = c.compare("3","7");
interesting thing :
var cats = new ArrayList<>(Arrays.asList(catNames));
Diamond Operator - compiler's type inference feature determines the most suitable constructor declaration that matches the invocation.
This is not a row type.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ASPushkin
2 months agoASPushkin
6 months, 1 week agomendjijet
11 months agoSamps
1 year agoOmnisumem
1 year, 4 months agoeldonivan
1 year, 4 months agotmuralimanohar
1 year, 6 months agoStavok
1 year, 7 months ago