Categories: Java Java Programming & Coding

Minimum using java8 stream api

package r4r.in;

public class MinimumUsingJava8StreamAPI  {

public static void main(String[] args) {

//Minimum using java8 stream api

Integer[] input = { 12, 122, -11, 120, 21, 23 };

int min1 = Stream.of(input).reduce(Integer::min).get();

System.out.println("Min using Stream reduce() mrthod =" + min1);

int min2 = Stream.of(input).reduce((x, y) -> x > y ? y : x).orElse(-1);

System.out.println("Min using Stream reduce() mrthod =" + min2);

}

}

R4R.in Team
The content on R4R.in website is created by expert teams.
|| Blockchain || Cisco CCNA || Selenium || Internet security || Thermostat || Fashion || Online Games || Working From Home(WFH) || COVID-19 || Games || Cryptocurrency || Digital economy || Property || Sundarban National Park || NEET Course || Investment || Java || Inverter battery || PDF Drive || Online Library || Yoga || Career || Sports || SEO || Software Engineering || APPs || Digital Marketing || Certified True Copy || Mobiles || Software Testing || Books || TAX || Foreign Currency || AutoCAD || Online Course || Machine || Python || Banks || Bitcoin || Education || German Language || Festivals || Health ||