- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to get the reverse of an Integer array with Lambda Expressions
Let us first declare and initialize an Integer array:
Integer[] arr = {20, 50, 75, 100, 120, 150, 170, 200};
To find the reverse of the Integer array with Lambda, use sort and the Lamda:
Arrays.sort(arr, (Integer one, Integer two) -> { return (two- one); });
The following is an example to reverse an Integer array with Lambda Expressions:
Example
import java.util.Arrays; public class Demo { public static void main(String[] args) { Integer[] arr = {20, 50, 75, 100, 120, 150, 170, 200}; System.out.println("Integer Array elements..."); for (int res : arr) { System.out.println(res); } Arrays.sort(arr, (Integer one, Integer two) -> { return (two- one); }); System.out.println("Reverse of Array elements..."); System.out.println(Arrays.toString(arr)); } }
Output
Integer Array elements... 20 50 75 100 120 150 170 200 Reverse of Array elements... [200, 170, 150, 120, 100, 75, 50, 20]
- Related Articles
- Java Program to initialize a HashMap with Lambda Expressions
- Java program to reverse an array
- C# Program to find the smallest element from an array using Lambda Expressions
- C# Program to find the largest element from an array using Lambda Expressions
- Java Program to get frequency of words with Lambda Expression
- Java Program to extend the size of an Integer array
- Reverse an Integer in Java
- Java Program to get the reverse of the NavigableSet
- Java Program to create a new list with values from existing list with Lambda Expressions
- Java program to reverse bits of a positive integer number
- Java program to reverse an array in groups of given size
- Java program to reverse an array upto a given position
- How to debug lambda expressions in Java?
- C# program to reverse an array
- Program to convert set of Integer to Array of Integer in Java

Advertisements