How to write min(a,b) instead of Math.min(a,b)

J

juergen

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
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

> 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
 
O

opalpa

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
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top