Introduction to Method

description of image


Java methods


A method is a block of code that performs a specific task.

Suppose, we need to write a program to create a circle and color it.

We can create two methods to solve this problem:

Create a circle method

Create a color method

Dividing a complex problem into smaller chunks makes our program easy to understand and reuse.



Call a Method


● Once we define a method, we need to call it to run the code inside the method body.



Quiz


Question Text