{"id":1158,"date":"2020-03-25T17:49:18","date_gmt":"2020-03-25T04:49:18","guid":{"rendered":"https:\/\/www.ronella.xyz\/?p=1158"},"modified":"2021-09-28T14:02:19","modified_gmt":"2021-09-28T01:02:19","slug":"sample-usage-of-teeing-collector","status":"publish","type":"post","link":"https:\/\/www.ronella.xyz\/?p=1158","title":{"rendered":"Sample Usage of Teeing Collector"},"content":{"rendered":"<pre style=\"white-space: pre;\">\/\/A Stream of Integers\r\nvar ints = Stream.of(10, 20, 30 , 40);\r\n\r\n\/\/Calculate the average using the Collectors.teeing method.\r\nlong average = ints.collect(\r\n        Collectors.teeing(\r\n                \r\n                \/\/Sum all of the integers in the stream.\r\n                Collectors.summingInt(Integer::valueOf),\r\n                \r\n                \/\/Count the content of the stream.\r\n                Collectors.counting(),\r\n                \r\n                \/\/Calculate the average.\r\n                ( sum, count) -&gt; sum \/ count\r\n        )\r\n);\r\n\r\nSystem.out.println(average);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/A Stream of Integers var ints = Stream.of(10, 20, 30 , 40); \/\/Calculate the average using the Collectors.teeing method. long average = ints.collect( Collectors.teeing( \/\/Sum all of the integers in the stream. Collectors.summingInt(Integer::valueOf), \/\/Count the content of the stream. Collectors.counting(), \/\/Calculate the average. ( sum, count) -&gt; sum \/ count ) ); System.out.println(average);<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[63,71],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/1158"}],"collection":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1158"}],"version-history":[{"count":1,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/1158\/revisions"}],"predecessor-version":[{"id":1159,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/1158\/revisions\/1159"}],"wp:attachment":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}