Methods in Java

What is a method?

A java method is a set of statements or steps that are grouped together to perform an operation
Method are also known as functions
When we use methods? – whenever we want to perform an operation multiple times
Advantage of methods – code reusability
Types of methods -  built in (predefined) and user defined

1. Built in Methods:

Java has a librabry of classes and methods organised in packages

In order to use built in methods we need to import packages or classes
Java.lang package is automatically imported in every java Built in methods categories
String methods
Array methods
Number methods
Character methods

2. User Defined Methods:

Different Method types:
Method without returning any values
Method with returning values
Method using passing parameters

Different ways to call Methods:
Using Objects
Without Using object
Call external methods (from external class)

To get more details please watch below youtube video and Subscribe the channel.



No comments:

Post a Comment