Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 Procedural Methods.

Similar presentations


Presentation on theme: "Chapter 4 Procedural Methods."— Presentation transcript:

1 Chapter 4 Procedural Methods

2 Objectives Identify classes, objects, and methods.
Identify the difference between a procedure method and a function method. Differentiate between parameters and arguments. Write procedure methods with parameters. Explain the purpose of the Java API.

3 Procedure Methods A procedural method is a coordinated sequence of instructions that will be carried out when requested.

4 Java Programming Interface (API)

5 Method Syntax The syntax for a method is:
modifier static returntype methodname ( list of parameters ) { .... statements to do inside of method } Modifiers determine the scope of a method. public means that the method is available in the current class (program) and other classes. private means that you intend to use the variable or method in the current program. Return Type Data type: int, double, float, etc. No return type: void

6 Naming Methods Consists of letters, digits, underscores (_) or $ (no spaces allowed). First character can't be a digit. Cannot be keywords. Stylistic Rule: all method names begin with a lowercase letter with all other words beginning with uppercase letter such as displayIt, sumNumbers, etc. Method names should be meaningful.

7 Methods with No Parameters

8 Methods with No Parameters

9 Methods with Some Parameters

10 Methods with Some Parameters

11 Object Methods

12 Static Methods


Download ppt "Chapter 4 Procedural Methods."

Similar presentations


Ads by Google