Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Software Development 1Slide 1 Methods: Defining, Invoking, Executing “There is a difference between knowing the path and walking the path.”

Similar presentations


Presentation on theme: "Fundamentals of Software Development 1Slide 1 Methods: Defining, Invoking, Executing “There is a difference between knowing the path and walking the path.”"— Presentation transcript:

1 Fundamentals of Software Development 1Slide 1 Methods: Defining, Invoking, Executing “There is a difference between knowing the path and walking the path.” ~ Morpheus“There is a difference between knowing the path and walking the path.” ~ Morpheus “There is a difference between defining a method and invoking a method.” ~ CS Prof.“There is a difference between defining a method and invoking a method.” ~ CS Prof.

2 Fundamentals of Software Development 1Slide 2 Methods Defining, Invoking, Executing Defining a MethodDefining a Method –Specifying stepwise directions for a method… For example you specify how a robot can pick up a soda can (think of this as “teaching”)you specify how a robot can pick up a soda can (think of this as “teaching”) Invoking a MethodInvoking a Method –Asking to activate a method… For example you ask the robot to pick up a soda canyou ask the robot to pick up a soda can Executing a MethodExecuting a Method –Processing the stepwise instructions specified in the method… For example the robot carries out your command to pick up the soda canthe robot carries out your command to pick up the soda can

3 Fundamentals of Software Development 1Slide 3 Defining a Method Questions? Syntax for a method definition: Example of a method definition: ReturnType methodName(ParameterType parameterName,...) { // Stepwise instructions } String transform(String inputString) { return  Caps:  + inputString.toUpperCase(); }

4 Fundamentals of Software Development 1Slide 4 Invoking and Executing a Method Format: object.method(arguments)Format: object.method(arguments) Invoke a String method:Invoke a String method: "Hello".toUpperCase() yields "HELLO" "Hello".toUpperCase() yields "HELLO" –"Hello".substring(3) yields "lo" –"Hello".substring(1, 3) yields "el" –"Hello".substring(0) yields "Hello“ Stringmethoddotarguments, in parentheses Numbering starts at zero Questions?


Download ppt "Fundamentals of Software Development 1Slide 1 Methods: Defining, Invoking, Executing “There is a difference between knowing the path and walking the path.”"

Similar presentations


Ads by Google