FileDocCategorySizeDatePackage
OverLoadReturn.javaAPI DocExample577Sat Nov 25 12:55:46 GMT 2000None

OverLoadReturn

public class OverLoadReturn extends Object
Can you overload a method to have two different return types?

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] a)

		System.out.println("Hello. Why did you call me up?");
		OverLoadReturn r = new OverLoadReturn();
		int i = method();
		String s = method();
	
intmethod()

		System.out.println("In int method");
		return 0;
	
java.lang.Stringmethod(java.lang.String input)

	// THIS WORKS
		System.out.println("In String method(String)");
		return input;
	
java.lang.Stringmethod()

				// EXPECT COMPILE ERROR
		System.out.println("In String method");
		return null;