Languages
[Edit]
EN

Java - Math.min() method example

0 points
Created by:
Vadim-Kotiv
414

The Math.min() function returns the smallest number from given numbers.


1. Documentation

Edit
Syntax

Note: Classes in the java.lang package are imported automatically, so it is not necessary to do it manually - we use just Math.min() call.

Parametersnumber1, number2 - values to compare.
Result

Minimal number value (primitive value).

It returns NaN if at least one of the provided values is not a number.

Descriptionmin is a static method that takes number arguments and returns the smallest one value.

2. Getting min value from array examples

Edit

2.1. With Collections.min method example

Edit

2.2. By comparing all the elements in the array

Edit

References

Edit
  1. Maxima and minima - Wikipedia

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java - Math object

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join