About 77,800 results
Open links in new tab
  1. java - How does math.min actually work? - Stack Overflow

    Sep 25, 2013 · In Java, the Math.min(a, b) function is used to determine the minimum value between two numbers a and b. It returns the smaller of the two values. It returns the smaller of the two values. The Math.min() method is a static method provided by the Math class in Java's standard library.

  2. Most efficient way to find smallest of 3 numbers Java?

    Mar 6, 2012 · So if you have identified that a seemingly trivial operation like the computation of the minimum of three numbers is the actual bottleneck (that is, the "critical 3%") in your application, then you may consider optimizing it. And in this case, this is actually possible: The Math#min(double,double) method in Java has very special semantics:

  3. Java Minimum and Maximum values in Array - Stack Overflow

    Aug 26, 2016 · your maximum, minimum method is right. but you don't print int to console! and... maybe better location change (maximum, minimum) methods . now (maximum, minimum) methods in the roop. it is need not.. just need one call. i suggest change this code

  4. Finding the max/min value in an array of primitives using Java

    Mar 13, 2015 · You can simply use the new Java 8 Streams but you have to work with int.. The stream method of the utility class Arrays gives you an IntStream on which you can use the min method.

  5. 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 value) { return Math.max(0, Math.min(value, 10)); } I'm wondering if there's an existing limit or range function I'm overlooking.

  6. Calculate the minimum and maximum for a function

    Aug 6, 2015 · I am looking for a way of calculating the minimum and maximum values for a function in Java. The program I am looking to create would see all the local minimums and maximums for a function which oscillates around the x-axis (This is not a school assignment, although I have mentioned cos(x) in the outline below).

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

    Jul 29, 2018 · My guess is that your teacher expects you to write an algorithm, using a loop, to do that. Not just to find a method doing it for you. The methods you found, as the message clearly says, and as the javadoc also says, just compare two integers. If your goal is to find methods in the Java library, then you need to read their javadoc. –

  8. Java- Looking for advice on calculating the min/max for a function …

    Aug 29, 2015 · Write a method inside Java to calculate all the places where the derivative of this function is zero (in the graph above, the function has about 30 or so values between 0 < t < 100). Inside the method, define a step interval to evaluate the function through a …

  9. How to find the minimum value in an ArrayList, along with the …

    Apr 14, 2013 · I need to get the index value of the minimum value in my arraylist in Java. MY arraylist holds several floats, and I'm trying to think of a way I can get the index number of the smallest float so I can use that index number elsewhere in my code. I'm a beginner, so please don't hate me. Thanks!

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

    even if java didn't have a min function, just put the code above in a function and call it min() and it will become self documenting :) – user890904 Commented Sep 19, 2011 at 19:59

Refresh