Declaration vs. definition
One basic dichotomy is whether or not a declaration contains a definition: for example, whether a variable or constant declaration
specifies its value, or only its type; and similarly whether a declaration of a function specifies the body (
implementation) of the function, or only its type signature. Not all languages make this distinction: in many languages, declarations always include a definition, and may be referred to as either "declarations" or "definitions", depending on the language. However, these concepts are distinguished in languages that require declaration before use (for which forward declarations are used), and in languages where interface and implementation are separated: the interface contains declarations, the implementation contains definitions. In informal usage, a "declaration" refers only to a pure declaration (types only, no value or body), while a "definition" refers to a declaration that includes a value or body. However, in formal usage (in language specifications), "declaration" includes
both of these senses, with finer distinctions by language: in C and C++, a declaration of a function that does not include a body is called a
function prototype, while a declaration of a function that does include a body is called a "function definition". In Java declarations occur in two forms. For public methods they can be presented in interfaces as method signatures, which consist of the method names, input types and output type. A similar notation can be used in the definition of
abstract methods, which do not contain a definition. The enclosing class can be instantiated, rather a new derived class, which provides the definition of the method, would need to be created in order to create an
instance of the class. Starting with
Java 8, the lambda expression was included in the language, which could be viewed as a function declaration. == Declarations and definitions ==