src/share/classes/java/lang/Character.java

Print this page
rev 6151 : imported patch reducers

@@ -7232,6 +7232,48 @@
             return block.toString().replace('_', ' ') + " "
                    + Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
         // should never come here
         return Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
     }
+
+    /**
+     * Adds two chars together as per the + operator.
+     * Suitable for conversion as a method reference to functional interfaces such
+     * as {@code BinaryOperator<Character>}.
+     *
+     * @param   a   an argument.
+     * @param   b   another argument.
+     * @return  the sum of {@code a} and {@code b}.
+     * @since 1.8
+     */
+    public static char sum(char a, char b) {
+        return (char) (a + b);
+    }
+
+    /**
+     * Returns the greater of two {@code char} values.
+     * Suitable for conversion as a method reference to functional interfaces such
+     * as {@code BinaryOperator<Character>}.
+     *
+     * @param   a   an argument.
+     * @param   b   another argument.
+     * @return  the larger of {@code a} and {@code b}.
+     * @since 1.8
+     */
+    public static char max(char a, char b) {
+        return (a >= b) ? a : b;
+    }
+
+    /**
+     * Returns the lesser of two {@code char} values.
+     * Suitable for conversion as a method reference to functional interfaces such
+     * as {@code BinaryOperator<Character>}.
+     *
+     * @param   a   an argument.
+     * @param   b   another argument.
+     * @return  the lesser of {@code a} and {@code b}.
+     * @since 1.8
+     */
+    public static char min(char a, char b) {
+        return (a <= b) ? a : b;
+    }
 }