fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public class Move {
  11.  
  12. private int score;
  13.  
  14. public Move(int score) {
  15. this.score = score;
  16. }
  17.  
  18. public int getScore() {
  19. return score;
  20. }
  21.  
  22. public int getScore(boolean doubleIt) {
  23. return score * 2;
  24. }
  25. }
  26.  
  27. public static void main( String[] args )
  28. {
  29.  
  30. List<Move> moves = new ArrayList<>();
  31. moves.sort(Comparator.comparingInt(Move::getScore).reversed());
  32.  
  33. }
  34. }
Compilation error #stdin compilation error #stdout 0.12s 4386816KB
stdin
Standard input is empty
compilation info
Main.java:31: error: incompatible types: cannot infer type-variable(s) T
        moves.sort(Comparator.comparingInt(Move::getScore).reversed());
                                          ^
    (argument mismatch; invalid method reference
      incompatible types: Object cannot be converted to boolean)
  where T is a type-variable:
    T extends Object declared in method <T>comparingInt(ToIntFunction<? super T>)
Main.java:31: error: invalid method reference
        moves.sort(Comparator.comparingInt(Move::getScore).reversed());
                                           ^
  non-static method getScore() cannot be referenced from a static context
2 errors
stdout
Standard output is empty