In  this tutorial, we will see “How to find the maximum and minimum of two numbers without using if-else but in fact with the help of streams in Java 8?”

find max and min of two numbers using Java 8 Streams

Java 8 – How to find the max and min of two numbers without using if-else statements? Click To Tweet

 

Output:

find max and min of two numbers using Java 8 Streams

In the above example, It uses Java 8’s IntStream class to convert an array of integers into a stream, and then finds the minimum and maximum values using the min() and max() methods, respectively.

Java 8 – How to find the max and min of two numbers without using if-else statements? Click To Tweet

Do you like this Post? – then check my other helpful posts:

Other Useful References: