How to invoke a method
 

When a method is invoked (called), a request is made to perform some action, such as setting a value, printing statements, returning an answer, etc. The code to invoke the method contains the name of the method to be executed and any needed data that the receiving method requires. The required data for a method are specified in the method's parameter list.

Consider this method that we have already been using from Breezy;

int number = Console.readInt("Enter a number"); //returns a value

The method name is "readInt" which is defined in the class "Console". Since the method is defined in the class Console, the word Console becomes the calling object. This particular method returns an integer value which is assigned to an integer variable named number.

You invoke (call) a method by writing down the calling object followed by a dot, then the name of the method, and finally a set of parentheses that may (or may not) have information for the method.

(c) Shilpa Sayura Foundation 2006-2017