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


which 1 faster in java , why?

  1. math.max(a,b)
  2. (a>b)?a:b

(this asked in interview.)

math.max(a, b) static function (meaning no virtual call overhead) , inlined jvm same instructions (a > b) ? : b.


Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -