Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
IntStream max() in Java with examples
Next article icon

IntStream rangeClosed() in Java

Last Updated : 06 Dec, 2018
Comments
Improve
Suggest changes
Like Article
Like
Report
IntStream rangeClosed(int startInclusive, int endInclusive) returns an IntStream from startInclusive (inclusive) to endInclusive (inclusive) by an incremental step of 1. Syntax :
  static IntStream rangeClosed(int startInclusive,   int endInclusive)  
Parameters :
  1. IntStream : A sequence of primitive int-valued elements.
  2. startInclusive : The inclusive initial value.
  3. endInclusive : The inclusive upper bound.
Return Value : A sequential IntStream for the range of int elements. Example : Java
// Implementation of IntStream rangeClosed // (int startInclusive, int endInclusive) import java.util.*; import java.util.stream.IntStream;  class GFG {      // Driver code     public static void main(String[] args)     {         // Creating an IntStream         IntStream stream = IntStream.rangeClosed(-4, 3);          // Displaying the elements in range         // including the lower and upper bound         stream.forEach(System.out::println);     } } 
Output:
  -4  -3  -2  -1  0  1  2  3  
Note : IntStream rangeClosed(int startInclusive, int endInclusive) basically works like a for loop. An equivalent sequence of increasing values can be produced sequentially as :
  for (int i = startInclusive; i <= endInclusive ; i++)   {   ...   ...   ...  }  

Next Article
IntStream max() in Java with examples

S

Sahil_Bansall
Improve
Article Tags :
  • Misc
  • Java
  • Java - util package
  • Java-Functions
  • java-stream
  • java-intstream
Practice Tags :
  • Java
  • Misc

Similar Reads

  • IntStream range() in Java
    IntStream range(int startInclusive, int endExclusive) returns a sequential ordered IntStream from startInclusive (inclusive) to endExclusive (exclusive) by an incremental step of 1. Syntax : static IntStream range(int startInclusive, int endExclusive) Parameters : IntStream : A sequence of primitive
    1 min read
  • IntStream skip() in Java
    In Java, the IntStream skip(long n) method returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream. If this stream contains less than n elements, then an empty stream will be returned. Note: IntStream skip() is a stateful intermediate
    2 min read
  • NavigableMap Interface in Java
    The NavigableMap interface is a member of the Java Collection Framework. It belongs to java.util package and It is an extension of SortedMap which provides convenient navigation methods for dealing with elements that are sorted based on their keys. This interface allows us to navigate through the ma
    11 min read
  • IntStream max() in Java with examples
    java.util.stream.IntStream in Java 8, deals with primitive ints. It helps to solve the problems like finding maximum value in array, finding minimum value in array, sum of all elements in array, and average of all values in array in a new way. IntStream max() returns an OptionalInt describing the ma
    2 min read
  • IntStream min() in Java with Examples
    java.util.stream.IntStream in Java 8, deals with primitive ints. It helps to solve the old problems like finding maximum value in array, finding minimum value in array, sum of all elements in array, and average of all values in array in a new way. IntStream min() returns an OptionalInt describing th
    2 min read
  • LinkedList indexOf() Method in Java
    In Java, the indexOf() method of the LinkedList class is used to find the index of the first occurrence of the specified element in the list. Syntax of LinkedList indexOf() Method public int indexOf(Object o); Parameter: This method takes an object "o" as an argument. Return type: It returns the ind
    2 min read
  • Infinite Loop Puzzles in Java
    In Java, Infinite loops are a very important concept to understand. Infinite loops can occur due to various reasons such as overflows, unboxing and logic comparisons. In this article, we will understand two common puzzles related to infinite loop. Problem 1: Infinite Loop Using Integer OverflowIn Ja
    3 min read
  • Instant range() method in Java with Examples
    The range() method of Instant class helps to get the range of valid values for the field passes as a parameter. This method returns ValueRange object which contains the minimum and maximum valid values for a field. This instant is helpful to enhance the accuracy of the returned range. When the field
    2 min read
  • EnumSet range() Method in Java
    The java.util.EnumSet.range(E start_point, E end_point) method in Java is used to create an enum set with the elements defined by the specified range in the parameters. Syntax: Enum_set = EnumSet.range(E start_point, E end_point) Parameters: The method accepts two parameters of the object type of en
    2 min read
  • Ints lastIndexOf() function | Guava | Java
    Guava's Ints.lastIndexOf() returns the index of the last appearance of the value target in array. Syntax: public static int lastIndexOf(int[] array, int target) Parameters: array: An array of int values, possibly empty. target: A primitive int value. Return Value: The Ints.indexOf() method returns t
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences