Object Oriented Software Engineering   View all facts   Glossary   Help
subject > programming language construct > procedure > constructor
Next proceduremethod    Upprocedure

constructor comparison table
Subject implement override return to have example have high cohesion is part of have purpose hide be have access by is a subtopic of lack is a kind of provide perform have advantage
Java constructor a method in a superclass with the same nameits caller from only one place which should be the last statement
public Account(String accountHolder, float initialBalance)
{
this.accountHolder = accountHolder;
balance = initialBalance;
opened = new Date();
}
public Account(String accountHolder)
{
this.accountHolder = accountHolder;
balance =0.0;
opened = new Date();
}
if related aspects of a system are kept together in this module, and unrelated aspects are kept outa classto initialize the instance variables of a newly created object and perform any other needed initializationthe details of procedurespublic except for those that will definitely need to be called from outside the packagethe same name as its classother methods and variables in any class in the same package by defaultThe Basics of Javaside effects if it does not modify any data, and does not leave behind any information, other than its result, that would have an effect on other computationsJava methodprocedural abstractiona special-purpose function such as the user interface for a particular systemwhen using a certain procedure, a programmer does not need to worry about all the details of how it performs its computations; he or she only needs to know how to call it and what it computes

Next proceduremethod    Upprocedure