A range is shorthand for specifying a sequence of values. A Range is denoted by the first and last values in the sequence, and Range can be inclusive or exclusive. An inclusive Range includes all the values from the first to the last, while an exclusive Range includes all values except the last. Here are some examples of Range literals −
Following are the various methods available for ranges.
|Sr.No.||Methods & Description|
Checks if a range contains a specific value
Returns the element at the specified position in this Range.
Get the lower value of this Range.
Get the upper value of this Range.
Is this a reversed Range, iterating backwards
Returns the number of elements in this Range.
Returns a view of the portion of this Range between the specified fromIndex, inclusive, and toIndex, exclusive