Download presentation
Presentation is loading. Please wait.
Published byAngelica Morris Modified over 9 years ago
1
Chapter 4 Procedural Methods
2
Learning Java through Alice © Daly and Wrigley 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. 2
3
Learning Java through Alice © Daly and Wrigley Procedure Methods A procedural method is a coordinated sequence of instructions that will be carried out when requested. 3
4
Learning Java through Alice © Daly and Wrigley Java Programming Interface (API) http://docs.oracle.com/javase/8/docs/api/ 4
5
Learning Java through Alice © Daly and Wrigley 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 5
6
Learning Java through Alice © Daly and Wrigley 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. 6
7
Learning Java through Alice © Daly and Wrigley Methods with No Parameters 7
8
Learning Java through Alice © Daly and Wrigley Methods with No Parameters 8
9
Learning Java through Alice © Daly and Wrigley Methods with Some Parameters 9
10
Learning Java through Alice © Daly and Wrigley Methods with Some Parameters 10
11
Learning Java through Alice © Daly and Wrigley Object Methods 11
12
Learning Java through Alice © Daly and Wrigley Static Methods 12
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.