hello,
could u pls tell me if there's any function which can allow java to decide what operator should use in order to return a min/max number?
if yes.. i'd be happy to see it.
i once saw something like this:
use "+,-,/" .. followed by i don't know what.. and i can't remember the function :angry: or the programm it was writen in.

i don't need the whole algorithm.. only the function
so if u pls know anythin.. thanks a lot! :)

I don't quite get what you mean here....but you said max and min.

So you could use the min and max functions that are in the language, it would be in the java.lang.Math. The functions are Min() and Max(). These allow you to compare two ints, longs, doubles, floats against each other.

No, there isn't. It sounds like you're talking about operator overloading, which Java, by a conscious decision, does not have.

No, there isn't. It sounds like you're talking about operator overloading, which Java, by a conscious decision, does not have.

ok, there isn't

but what about other programming lang?
can they do that?

thks :)

ok, there isn't

but what about other programming lang?
can they do that?

thks :)

I think you're going to have to explain the problem a little more clearly. An example of a language that uses operator overloading is C++, but I don't understand what you are trying to do.

ok,

so i have a few operators, let's say "+, -, *" and i need a progr lang
(in our case c++) to create a function in order to obtain a maximum, medium and minimum values using int a,b,c (not given values)

something like this:

int a; int b; int c;
using "+, -, *"
create function.....
resulting min, mid and max values


tnks a lot
depnew:)

Even if you do come up with an algorithm for that you will still need to make some comparison.So why don't you try this:

public int max(int a, int b, int c) {
  if ((a>=b)&&(a>=c)) {
    return a;
 }
if ((b>=a)&&(b>=c)) {
    return b;
 }
return c;
}

You cannot overload these : "+", "-", "*", "/" in java. You need to write your own functions that do what you want.
I would suggest to try the C# forum

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.