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++ - Convert big endian to little endian when reading from a binary file -

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

unicode - Are email addresses allowed to contain non-alphanumeric characters? -