Is Math.max(a,b) or (a>b)?a:b faster in Java?

Here is the openjdk code for Math.max() in Java:

public static int max(int a, int b) {
    return (a >= b) ? a : b;
}

So, the code would probably be (almost) exactly the same speed.

(Lets be honest, if you are worrying about speed improvements at such a low level, you probably have far greater problems in your code.)

Leave a Comment

techhipbettruvabetnorabahisbahis forumu