Movatterモバイル変換


[0]ホーム

URL:


Open In App
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 int-valued elements.
  • startInclusive :The inclusive initial value.
  • endExclusive :The exclusive upper bound.
  • Return Value :A sequential IntStream for the range of int elements.Example :Java
    // Implementation of IntStream range// (int startInclusive, int endExclusive)importjava.util.*;importjava.util.stream.IntStream;classGFG{// Driver codepublicstaticvoidmain(String[]args){// Creating an IntStreamIntStreamstream=IntStream.range(6,10);// Displaying the elements in range// including the lower bound but// excluding the upper boundstream.forEach(System.out::println);}}
    Output:
    6789
    Note :IntStream range(int startInclusive, int endExclusive) basically works like a for loop. An equivalent sequence of increasing values can be produced sequentially as :
    for (int i = startInclusive; i < endExclusive ; i++) { ... ... ...}

    Improve

    Explore

    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

    [8]ページ先頭

    ©2009-2025 Movatter.jp