JAVA8 Calculation of Object properties

Source: Internet
Author: User

Men's Men =NewMen (); Men.setname ("UU"); Men.setage ("56"); Men Men1=NewMen (); Men1.setname ("KK"); Men1.setage ("23"); Men Men2=NewMen (); Men2.setname ("KK"); Men2.setage (""); List<Men> list =NewArraylist<>();        List.add (men);        List.add (MEN1);                List.add (MEN2); //General Wording        intSum =0;  for(men men3:list) {if(Men3.getname (). Equals ("KK") ) {sum= Sum + integer.parseint (Men3.getage (). IsEmpty ()? " 0 ": Men3.getage ()); }        }        //JAVA8 new Features        intKK =list. Stream (). Filter (tT.getname (). Equals ("KK"). Maptoint (tInteger.parseint (T.getage (). IsEmpty ()? " 0 ": T.getage ()))                . sum (); System.out.println (KK);

JAVA8 Calculation of Object properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.