We would like to know how to sort Integer array with static reference and output with static reference.
/*from w w w .j a v a2s . c o m*/ import java.util.Arrays; import java.util.stream.Stream; public class Main { public static void main(String[] args) { Integer[] numbers = new Integer[]{2, 7, 3, 9, 5, 4, 6, 8, 1}; Arrays.sort(numbers, Integer::compareTo); Stream.of(numbers).forEach(System.out::println); } }
The code above generates the following result.