0% found this document useful (0 votes)
3 views

ITE2 Methods

Uploaded by

dominicraz1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

ITE2 Methods

Uploaded by

dominicraz1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

METHODS ‘-

CRISTY S. CARPON
COLLEGE OF COMPUTING AND INFORMATION SCIENCES

1
What is a method?
 Often called as modules or function.
 a block of code that performs a specific
‘-
task.
 used to divide complicated programs into
manageable pieces.
 can be used to define reusable code and
organize and simplify coding 2
Types of Java Methods
 Predefined Methods
 built-in methods in Java that are
‘-
readily available for use
 User-defined Methods
 Methods that created by the user.
3
Example of Predefined Methods

‘-

4
User-Defined Methods Categories

‘-

5
‘-

6
‘-

7
‘-

8
How to call a Java Method?

‘-

9
‘-

10
Example

‘-

11
‘-

12
‘-

13
Void Methods

‘-

14
‘-

15
‘-

16
‘-

17
Exercise
1. Write a program that will find the sum of three
numbers using methods.
2. Write a program that will compute the sum of the
‘-
sequence numbers from 1 to N where N is a
supplied value entered by the user.
3. Write a program that will ask the user to input two
numbers and then the program will swap or
interchange the arrangement of two numbers given
by the user. 18

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy