Monday, July 5, 2010
Overloading Methods
Method overloading is one of the ways that Java implements polymorphism. When two or more methods within the same class share the same name but differ in the type and/or number of their parameters then those methods are said to be overloaded. While overloaded methods may have different return types, the return type alone is insufficient to distinguish two versions of a method. When Java encounters a call to an overloaded method, it simply executes the version of the method whose parameters match the arguments used in the call. Java uses the type and/or number of arguments as its guide to determine which version of the overloaded method to actually call.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment