src/share/classes/java/lang/Integer.java
Print this page
rev 6151 : imported patch reducers
*** 1510,1517 ****
--- 1510,1559 ----
((i >> 8) & 0xFF00) |
((i << 8) & 0xFF0000) |
((i << 24));
}
+ /**
+ * Adds two integers together as per the + operator.
+ * Suitable for conversion as a method reference to functional interfaces such
+ * as {@code BinaryOperator<Integer>} or {@code IntBinaryOperator}.
+ *
+ * @param a an argument.
+ * @param b another argument.
+ * @return the sum of {@code a} and {@code b}.
+ * @since 1.8
+ */
+ public static int sum(int a, int b) {
+ return a + b;
+ }
+
+ /**
+ * Returns the greater of two {@code int} values.
+ * Suitable for conversion as a method reference to functional interfaces such
+ * as {@code BinaryOperator<Integer>} or {@code IntBinaryOperator}.
+ *
+ * @param a an argument.
+ * @param b another argument.
+ * @return the larger of {@code a} and {@code b}.
+ * @since 1.8
+ */
+ public static int max(int a, int b) {
+ return (a >= b) ? a : b;
+ }
+
+ /**
+ * Returns the lesser of two {@code int} values.
+ * Suitable for conversion as a method reference to functional interfaces such
+ * as {@code BinaryOperator<Integer>} or {@code IntBinaryOperator}.
+ *
+ * @param a an argument.
+ * @param b another argument.
+ * @return the lesser of {@code a} and {@code b}.
+ * @since 1.8
+ */
+ public static int min(int a, int b) {
+ return (a <= b) ? a : b;
+ }
+
/** use serialVersionUID from JDK 1.0.2 for interoperability */
private static final long serialVersionUID = 1360826667806852920L;
}