public class Range extends Object
Iterables to use with the enhanced for loop.
Instead of
for (int index = 0; index < 10; ++index) {
…
}
you can now write
for (int index : Range.create(10)) {
…
}
| Constructor and Description |
|---|
Range() |
| Modifier and Type | Method and Description |
|---|---|
static Iterable<Integer> |
create(int upperBound)
Creates a new range from
0 (inclusive) to the given upper bound
(exclusive). |
static Iterable<Integer> |
create(int lowerBound,
int upperBound)
Creates a new range from the given lower bound (inclusive) to the given
upper bound (exclusive).
|
static Iterable<Long> |
create(long upperBound)
Creates a new range from
0 (inclusive) to the given upper bound
(exclusive). |
static Iterable<Long> |
create(long lowerBound,
long upperBound)
Creates a new range from the given lower bound (inclusive) to the given
upper bound (exclusive).
|
public static Iterable<Integer> create(int upperBound)
0 (inclusive) to the given upper bound
(exclusive).upperBound - The upper bound of the range (exclusive)public static Iterable<Integer> create(int lowerBound, int upperBound)
lowerBound - The lower bound of the range (inclusive)upperBound - The upper bound of the range (exclusive)public static Iterable<Long> create(long upperBound)
0 (inclusive) to the given upper bound
(exclusive).upperBound - The upper bound of the range (exclusive)public static Iterable<Long> create(long lowerBound, long upperBound)
lowerBound - The lower bound of the range (inclusive)upperBound - The upper bound of the range (exclusive)Copyright © 2026. All rights reserved.