Guest User

Untitled

a guest
Oct 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. class Ideone {
  2. public static void main (String[] args) throws java.lang.Exception {
  3. Integer a[] = {1,2,3,4,5,6,7};
  4. int b[] = {1,2,3,4,5,6,7};
  5.  
  6. Arrays.sort(a, (x,y) -> y-x);
  7. //Arrays.sort(b, (x,y) -> y-x);
  8.  
  9. System.out.println(Arrays.toString(a));
  10. System.out.println(Arrays.toString(b));
  11. }
  12. }
  13.  
  14. Main.java:11: error: no suitable method found for sort(int[],(x,y)->y - x)
  15. Arrays.sort(b, (x,y) -> y-x);
  16. ^
  17. method Arrays.<T#1>sort(T#1[],Comparator<? super T#1>) is not applicable
  18. (inference variable T#1 has incompatible bounds
  19. equality constraints: int
  20. upper bounds: Object)
  21. method Arrays.<T#2>sort(T#2[],int,int,Comparator<? super T#2>) is not applicable
  22. (cannot infer type-variable(s) T#2
  23. (actual and formal argument lists differ in length))
  24. where T#1,T#2 are type-variables:
  25. T#1 extends Object declared in method <T#1>sort(T#1[],Comparator<? super T#1>)
  26. T#2 extends Object declared in method <T#2>sort(T#2[],int,int,Comparator<? super T#2>)
  27. Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
  28. 1 error
  29.  
  30. b = IntStream.of(b)
  31. .boxed()
  32. .sorted(Comparator.reverseOrder())
  33. .mapToInt(i -> i)
  34. .toArray();
  35.  
  36. Primitive.sort(b, (i1, i2) -> Double.compare(i2, i1), false);
Add Comment
Please, Sign In to add comment