boolean mergeable(Range r){
  return (1 + Math.max(last,r.last) - Math.min(first,r.first)) <= ((1 + r.last - r.first) + (1 + last - first));
}

boolean mergeable ( Range r ) { return ( 1 + Math . max ( last , r . last ) - Math . min ( first , r . first ) ) <= ( ( 1 + r . last - r . first ) + ( 1 + last - first ) ) ; }
tests whether the specified range is mergeable with the target range . two ranges are mergeable if they can be replaced with a single range that spans exactly the same range of values .
