CPSC 233 Lecture 7: 8Feb
Document Summary
If you don"t supply a constructor, a default no-arg constructor is provided automaically: it does nothing; equivalent to: public class complex { public complex() { This can be used to send a self reference to another object: eg: Where 2 or more methods have the same name but diferent signatures: signature: the method name plus the parameter list. This return type is not part of the signature. Allows you to give the same name to related methods. The compiler uses signature matching to determine which method to call: eg: public class mymath public static double square(double x) return x*x; public static int square(int x) return x*x; //client code int i=5,j; double d=3. 6,e; j=mymath. square(i); e=mymath. square(d); An object may eventually be garbage collected once all references to the object are eliminated: done at the gc"s discreion, you can usually force garbage collecion with: Is invoked by the system just before an object is garbage collected: you can"t call inalize() directly.