We would like to know how to reverse Integer array.
import java.util.Arrays; /*from w w w . j a v a2 s. co m*/ public class Main { public static void main(String[] args) { Integer[] numbers = {1, 2, 3}; // reverse with lambda reverseWithLambda(numbers); System.out.println(Arrays.toString(numbers)); } private static void reverseWithLambda(Integer[] numbers) { Arrays.sort(numbers, (Integer i1, Integer i2) -> { return (i2 - i1); }); } }
The code above generates the following result.