Categories: Java Java Programming & Coding

package r4r.in;

public class MaximumUsingJava8StreamAPI  {

public static void main(String[] args) {

//Maximum using java8 stream api

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

int max1 = Stream.of(input).reduce(Integer::max).orElse(-1);

System.out.println("Max using Stream reduce() mrthod =" + max1);

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

System.out.println("Max using Stream reduce() mrthod =" + max2);

}

}

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 ||