CATEGORII DOCUMENTE |
Asp | Autocad | C | Dot net | Excel | Fox pro | Html | Java |
Linux | Mathcad | Photoshop | Php | Sql | Visual studio | Windows | Xml |
If the methods have the same name, how can Java know which method you mean? There's a simple rule: Each overloaded method must take a unique list of argument types.
If you think about this for a second, it makes sense: how else could a programmer tell the difference between two methods that have the same name, other than by the types of their arguments?
Even differences in the ordering of arguments is sufficient to distinguish two methods: (Although you don't normally want to take this approach, as it produces difficult-to-maintain code.)
//: OverloadingOrder.java
// Overloading based on the order of
// the arguments.
public class OverloadingOrder
static void print(int i, String s)
public static void main(String[] args)
The two print( ) methods have identical arguments, but the order is different, and that's what makes them distinct.
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 560
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved