I believe I had read somewhere how to do this but I cannot remember how
to do it.
I tried
import java.lang.Math;
or
import java.lang.Math.*;
but it doesn't work. Could someone help me? Thnx!
Juergen
Chris Brat - 19 Sep 2006 12:17 GMT
import static java.lang.Math.min;
> I believe I had read somewhere how to do this but I cannot remember how
> to do it.
[quoted text clipped - 4 lines]
> but it doesn't work. Could someone help me? Thnx!
> Juergen
Arne Vajhøj - 20 Sep 2006 00:11 GMT
>> I believe I had read somewhere how to do this but I cannot remember how
>> to do it.
[quoted text clipped - 3 lines]
>> import java.lang.Math.*;
>> but it doesn't work. Could someone help me? Thnx!
> import static java.lang.Math.min;
And it requires Java 1.5 or newer.
The point is the static keyword. The * works with static too.
Arne
opalpa@gmail.com opalinski from opalpaweb - 20 Sep 2006 05:20 GMT
If you want to be able to write "min(a,b)" you can make a class method
named min that invokes Math.min(a,b). ... Works in every jdk
static private int min(int a, int b) {
return Math.min(a,b);
}
Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/
> I believe I had read somewhere how to do this but I cannot remember how
> to do it.
[quoted text clipped - 4 lines]
> but it doesn't work. Could someone help me? Thnx!
> Juergen