/home/wpollock1/public_html/Java/Overload.java
// Demonstration of Java overloaded name resolution. In Java,
// if the method call ("invocation") doesn't exactly match any
// method signature, then the closest match where the arguments
// are of a larger size (or more general object type) is called.
//
// Written 1999-2006 by Wayne Pollock, Tampa Florida USA.
public class Overload
{
public static void main ( String [] args )
{
aMethod( 3 );
}
static void aMethod ( double d )
{
System.out.println( "aMethod(double) was called" );
}
/*
// Methods that only differ in their return types or modifiers
// are NOT allowed. So the following would cause errors:
static int aMethod ( double d ) {}
public static void aMethod ( double d ) {}
*/
static void aMethod ( long l ) // Comment out this method
{ // and see what happens!
System.out.println( "aMethod(long) was called" );
}
static void aMethod ( float f )
{
System.out.println( "aMethod(float) was called" );
}
}
/* Test your understanding: What happens in the following case?
testMethod( 3, 4 );
static void testMethod ( int i, double d )
{
System.out.println( "testMethod(int,double) was called" );
}
static void testMethod ( double d, int i )
{
System.out.println( "testMethod(double,int) was called" );
}
*/