공부/자바

[자바] 삼항연산자 안에 삼항연산자

ghhong 2022. 4. 5. 10:44

/**
     * Compares two {@code int} values numerically.
     * The value returned is identical to what would be returned by:
     * <pre>
     *    Integer.valueOf(x).compareTo(Integer.valueOf(y))
     * </pre>
     *
     * @param  x the first {@code int} to compare
     * @param  y the second {@code int} to compare
     * @return the value {@code 0} if {@code x == y};
     *         a value less than {@code 0} if {@code x < y}; and
     *         a value greater than {@code 0} if {@code x > y}
     * @since 1.7
     */


    public static int compare(int x, int y) {
        return (x < y) ? -1 : ((x == y) ? 0 : 1);
    }

'공부 > 자바' 카테고리의 다른 글

[tomcat] tomcat에서 jsession만드는방법  (0) 2022.06.24
[자바] 자바의 정석 정리(내가 다시 볼 것들만)  (0) 2022.05.04
[java] garbage collection  (0) 2022.02.03
[java] jvm, hotspot jvm  (0) 2022.02.03
[java] Optional  (0) 2021.12.08