About 53 results
Open links in new tab
  1. Is Math.max(a,b) or (a>b)?a:b faster in Java? - Stack Overflow

    Jul 15, 2016 · 30 Math.max(a, b) is a static function (meaning no virtual call overhead) and will likely be inlined by the JVM to the same instructions as (a > b) ? a : b.

  2. min (a,b) and max (a,b) equivalent in Java? - Stack Overflow

    1 Yes, the Math class contains two static methods called max and min which behaves according to their names. Take a look at this link. Here you will find some useful examples.

  3. How to find maximum value of set of variables - Stack Overflow

    Feb 16, 2012 · I was wondering if anyone could help me find the maximum value of a set of variables and assign them to another variable. Here is a snippet of my code that may help with …

  4. math - Find the max of 3 numbers in Java with different data types ...

    @mlissner Yes, use a loop and a variable max, check for every variable whether or not they are larger than max, if so: set max to that variable. Assuming your n values are in an array of course.

  5. java - How to create max method that gets 4 numbers and returns …

    I'm trying to build a method that would get 4 numbers and returns the maximum number of them. I tried to write this code that gets 4 numbers but this not working: Input and output: double a = …

  6. Java - limit number between min and max - Stack Overflow

    I want to return the number as long as it falls within a limit, else return the maximum or minimum value of the limit. I can do this with a combination of Math.min and Math.max. public int limit(int

  7. Need to find a max of three numbers in java - Stack Overflow

    Oct 9, 2012 · Find the max of 3 numbers in Java with different data types (Basic Java) Write a program that uses a scanner to read three integers (positive) displays the biggest number of …

  8. java - How to use Math.min and Math.max in integer array - Stack …

    Jul 29, 2018 · How to use Math.min and Math.max in integer array Asked 7 years, 5 months ago Modified 7 years, 5 months ago Viewed 16k times

  9. java - Finding the max of an int and a double? - Stack Overflow

    Mar 4, 2019 · First off, if you just use parameters of type double, Java will automatically perform a primitive conversion from int to double. Second, you can indeed use Math.max of compare the …

  10. java - Max/Min of three or more Integers if null values are allowed ...

    Apr 13, 2023 · Stream.of(value1, value2, value3) .filter(Objects::nonNull) .reduce(Math::max) .orElse(defaultValue); This creates a Stream containing the three values, filters out the nulls, …