I know that it is possible to do the following:
[tt]
public void method(int int_value)
{
//...
}
public void method(float float_value)
{
//...
}
public void method(String string_value)
{
//...
}
[/tt]
And-so-on-and-so-forth. But is it possible to do this:
[tt]
public int method()
{
//...
}
public float method()
{
//...
}
public String method()
{
//...
}
[/tt]
If so, when you were to, for example, write:
[tt]
float x;
x = method();
[/tt]
Would the compiler automatically run the 'float' version of the method? What if it was less clear, i.e.
[tt]
System.out.println("Good morning Dave, this is " + method() + " speaking."
[/tt]
Would method() return 42, 3.14, or "HAL"?
Hmm... a mystery! ***
Dammit Jim, I'm a programmer, not a doctor.
[tt]
public void method(int int_value)
{
//...
}
public void method(float float_value)
{
//...
}
public void method(String string_value)
{
//...
}
[/tt]
And-so-on-and-so-forth. But is it possible to do this:
[tt]
public int method()
{
//...
}
public float method()
{
//...
}
public String method()
{
//...
}
[/tt]
If so, when you were to, for example, write:
[tt]
float x;
x = method();
[/tt]
Would the compiler automatically run the 'float' version of the method? What if it was less clear, i.e.
[tt]
System.out.println("Good morning Dave, this is " + method() + " speaking."
[/tt]
Would method() return 42, 3.14, or "HAL"?
Hmm... a mystery! ***
Dammit Jim, I'm a programmer, not a doctor.