declaration vs definition : Java Glossary


declaration vs definition

In C++ you first declare the method headers defining the types of the parameters, but giving no details on how the method is computed. Then you later define the method procedure bodies. The idea is external code only looks at the declarations. External code does not need to be recompiled unless the definitions change. Everything in the declarations is repeated in the definitions and must be manually kept in sync.

Java has a more streamlined system. An ordinary Java method acts as both a declaration to inform callers of the parameters needed and a definition to elaborate how to compute the method. In addition, Java has abstract methods and their close cousins, interface methods, which act as pure declarations. When these template methods are implemented or overridden, they act like definitions.

This page is posted
on the web at:

Optional Replicator mirror
on local hard disk J:

Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Your face IP:[]
You are visitor number