Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/util/function/BinaryOperator#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/util/function/BinaryOperator#inhmethods)

# BinaryOperator

` public interface BinaryOperator `   
` implements https://developer.android.com/reference/java/util/function/BiFunction<T, T, T> `

|---|
| java.util.function.BinaryOperator\<T\> |

<br />

*** ** * ** ***

Represents an operation upon two operands of the same type, producing a result of the same type as the operands. This is a specialization of `https://developer.android.com/reference/java/util/function/BiFunction` for the case where the operands and the result are all of the same type.

This is a [functional interface](https://developer.android.com/reference/java/util/function/package-summary) whose functional method is `https://developer.android.com/reference/java/util/function/BiFunction#apply(T,%20U)`.
**See also:**

- `https://developer.android.com/reference/java/util/function/BiFunction`
- `https://developer.android.com/reference/java/util/function/UnaryOperator`

## Summary

| ### Public methods ||
|---|---|
| ` static <T> https://developer.android.com/reference/java/util/function/BinaryOperator<T>` | ` https://developer.android.com/reference/java/util/function/BinaryOperator#maxBy(java.util.Comparator<?%20super%20T>)(https://developer.android.com/reference/java/util/Comparator<? super T> comparator) ` Returns a `https://developer.android.com/reference/java/util/function/BinaryOperator` which returns the greater of two elements according to the specified `Comparator`. |
| ` static <T> https://developer.android.com/reference/java/util/function/BinaryOperator<T>` | ` https://developer.android.com/reference/java/util/function/BinaryOperator#minBy(java.util.Comparator<?%20super%20T>)(https://developer.android.com/reference/java/util/Comparator<? super T> comparator) ` Returns a `https://developer.android.com/reference/java/util/function/BinaryOperator` which returns the lesser of two elements according to the specified `Comparator`. |

### Inherited methods

From interface ` https://developer.android.com/reference/java/util/function/BiFunction ` ` default <V> https://developer.android.com/reference/java/util/function/BiFunction<T, T, V>` ` https://developer.android.com/reference/java/util/function/BiFunction#andThen(java.util.function.Function<?%20super%20R,?%20extends%20V>)(https://developer.android.com/reference/java/util/function/Function<? super R, ? extends V> after) `

Returns a composed function that first applies this function to its input, and then applies the `after` function to the result.
` abstract T` ` https://developer.android.com/reference/java/util/function/BiFunction#apply(T,%20U)(T t, T u) `

Applies this function to the given arguments.

## Public methods

### maxBy

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static BinaryOperator<T> maxBy (Comparator<? super T> comparator)
```

Returns a `https://developer.android.com/reference/java/util/function/BinaryOperator` which returns the greater of two elements according to the specified `Comparator`.

<br />

| Parameters ||
|---|---|
| `comparator` | `Comparator`: a `Comparator` for comparing the two values <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/function/BinaryOperator<T>` | a `BinaryOperator` which returns the greater of its operands, according to the supplied `Comparator` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the argument is null |

### minBy

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static BinaryOperator<T> minBy (Comparator<? super T> comparator)
```

Returns a `https://developer.android.com/reference/java/util/function/BinaryOperator` which returns the lesser of two elements according to the specified `Comparator`.

<br />

| Parameters ||
|---|---|
| `comparator` | `Comparator`: a `Comparator` for comparing the two values <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/function/BinaryOperator<T>` | a `BinaryOperator` which returns the lesser of its operands, according to the supplied `Comparator` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the argument is null |