該方法給出兩個參數(shù)中較小的一個。參數(shù)可以是int,float,long,double。
double min(double arg1, double arg2) float min(float arg1, float arg2) int min(int arg1, int arg2) long min(long arg1, long arg2)
參數(shù) - 此方法接受任何原始數(shù)據(jù)類型作為參數(shù)。
返回值 - 此方法返回兩個參數(shù)中較小的一個。
下面是一個使用這個方法的例子 -
class Example { static void main(String[] args) { System.out.println(Math.min(12.123, 12.456)); System.out.println(Math.min(23.12, 23.0)); } }
當(dāng)我們運行上面的程序,我們將得到以下結(jié)果 -
12.123 23.0
更多建議: