February 2014
Beginner
1248 pages
62h 25m
English
The compiler distinguishes overloaded methods by their signatures—a combination of the method’s name and the number, types and order of its parameters, but not its return type. If the compiler looked only at method names during compilation, the code in Fig. 6.10 would be ambiguous—the compiler would not know how to distinguish between the two square methods (lines 14–19 and 22–27). Internally, the compiler uses longer method names that include the original method name, the types of each parameter and the exact order of the parameters to determine whether the methods in a class are unique in that class.
For example, in Fig. 6.10, the compiler might (internally) use the logical name “square of int” for ...
Read now
Unlock full access