Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

min()

Example

Retrieve the minimum value from various pairs of numbers.

System.out.println(Math.min(2.0, 0.25));
System.out.println(Math.min(31.2f, 18.0f));
System.out.println(Math.min(14, 22));
System.out.println(Math.min(96L, 2048L));

Definition and Usage

The min() method retrieves the number with the lowest value from a pair of numbers.

To obtain the number with the highest value, you can utilize the max() method.

Syntax

One of the following:

public static double min(double x, double y)
public static float min(float x, float y)
public static int min(int x, int y) 
 public static long min(long x, long y)

Parameter Values

Parameter

Description

x

Please provide a number.

y

Please provide a number.

Technical Details

Returns

Please provide a numerical value that represents the smaller of two numbers, which could be a double, float, int, or long.

Java Version

Any