The Java.lang.math.min() function is an inbuilt function in java which returns minimum of two numbers. The arguments are taken in int, double, float and long.If a negative and a positive number is passed as argument then the positive result is generated. And if both parameters passed are negative then the number with the higher magnitude is generated as result.
dataType min(dataType num1, dataType num2) The datatypes can be int, float, double or long. Parameters : The function accepts two parameters num1 and num2 among which the minimum is returned
Return value:The function returns minimum of two numbers. The datatype will be the same as that of the arguments.
Given below are the examples of the function min():
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Java is Strictly Pass by Value!
- Fast I/O in Java in Competitive Programming
- Arrays.sort() in Java with examples
- Stack peek() Method in Java
- String vs StringBuilder vs StringBuffer in Java
- HashSet vs TreeSet in Java
- ShortBuffer allocate() method in Java With Examples
- IntBuffer duplicate() method in Java with Examples
- ShortBuffer compact() method in Java With Examples
- LongBuffer equals() method in Java