android/guava/src/com/google/common/collect/ImmutableSortedMap.java
@Override
  public ImmutableSortedMap<K, V> subMap(
      K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
    checkNotNull(fromKey);
    checkNotNull(toKey);
    checkArgument(
        comparator().compare(fromKey, toKey) <= 0,
        "expected fromKey <= toKey but %s > %s",
        fromKey,
        toKey);
    return headMap(toKey, toInclusive).tailMap(fromKey, fromInclusive);
  }
@Override
  public ImmutableSortedMap<K, V> subMap(
      K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
    checkNotNull(fromKey);
    checkNotNull(toKey);
    checkArgument(
        comparator().compare(fromKey, toKey) <= 0,
        "expected fromKey <= toKey but %s > %s",
        fromKey,
        toKey);
    return headMap(toKey, toInclusive).tailMap(fromKey, fromInclusive);
  }
This method returns a {@code ImmutableSortedMap}, consisting of the entries whose keys ranges
from {@code fromKey} to {@code toKey}, inclusive or exclusive as indicated by the boolean
flags.

<p>The {@link SortedMap#subMap} documentation states that a submap of a submap throws an {@link
IllegalArgumentException} if passed a {@code fromKey} less than an earlier {@code fromKey}.
However, this method doesn't throw an exception in that situation, but instead keeps the
original {@code fromKey}. Similarly, this method keeps the original {@code toKey}, instead of
throwing an exception, if passed a {@code toKey} greater than an earlier {@code toKey}.

@since 12.0