{"id":418,"date":"2018-05-29T13:05:16","date_gmt":"2018-05-29T01:05:16","guid":{"rendered":"https:\/\/content.ronella.xyz\/apps\/wordpress\/?p=418"},"modified":"2018-05-29T13:05:16","modified_gmt":"2018-05-29T01:05:16","slug":"range-in-java","status":"publish","type":"post","link":"https:\/\/www.ronella.xyz\/?p=418","title":{"rendered":"Range in Java"},"content":{"rendered":"<p>To create a range in java we can use the following from the <strong>java.util.stream<\/strong> package:<\/p>\n<ul>\n<li>IntStream.range(int startInclusive, int endExclusive)<\/li>\n<li>IntStream.rangeClosed(int\u00a0startInclusive, int endInclusive)<\/li>\n<li>LongStream.range(int startInclusive, int endExclusive)<\/li>\n<li>LongStream.rangeClosed(int\u00a0startInclusive, int endInclusive)<\/li>\n<\/ul>\n<h4>IntStream.range Method Example<\/h4>\n<pre>IntStream.range(1, 10).forEach(item -&gt; System.out.println(item));<\/pre>\n<p><strong>Output<\/strong><\/p>\n<pre>1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9<\/pre>\n<h4>IntStream.rangeClosed Method Example<\/h4>\n<pre>IntStream.rangeClosed(1, 10).forEach(item -&gt; System.out.println(item));<\/pre>\n<p><strong>Output<\/strong><\/p>\n<pre>1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To create a range in java we can use the following from the java.util.stream package: IntStream.range(int startInclusive, int endExclusive) IntStream.rangeClosed(int\u00a0startInclusive, int endInclusive) LongStream.range(int startInclusive, int endExclusive) LongStream.rangeClosed(int\u00a0startInclusive, int endInclusive) IntStream.range Method Example IntStream.range(1, 10).forEach(item -&gt; System.out.println(item)); Output 1 2 3 4 5 6 7 8 9 IntStream.rangeClosed Method Example IntStream.rangeClosed(1, 10).forEach(item -&gt; System.out.println(item)); Output 1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[33],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/418"}],"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=418"}],"version-history":[{"count":2,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/418\/revisions"}],"predecessor-version":[{"id":420,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/418\/revisions\/420"}],"wp:attachment":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}