Class Range


  • public class Range
    extends java.lang.Object
    Range describes a contiguous region in a series of items.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int length
      The number of items in the range.
      int location
      The start index of the range.
    • Constructor Summary

      Constructors 
      Constructor Description
      Range​(int location, int length)
      Creates a new range with the specified start index and number of items.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(int location)
      Returns a boolean value indicating whether or not the specified location is in this range.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • location

        public int location
        The start index of the range. 0 indicates the first item in the series.
      • length

        public int length
        The number of items in the range. May be 0 to indicate an empty range.
    • Constructor Detail

      • Range

        public Range​(int location,
                     int length)
        Creates a new range with the specified start index and number of items.
        Parameters:
        location - The start index of the range.
        length - The number of items in the range. May be 0 to indicate an empty range.
    • Method Detail

      • contains

        public boolean contains​(int location)
        Returns a boolean value indicating whether or not the specified location is in this range. The location is in this range if it's greater than or equal to this.location and less than this.location + this.length.
        Parameters:
        location - the location to test.
        Returns:
        true if the location is in this range, otherwise false.