Video-23 Method in JAVA | what is the method/function

Veröffentlicht am: 01 Januar 1970
auf dem Kanal: Explore More
17
2

In general, a method is a way to perform some task. Similarly, the method in Java is a collection of instructions that performs a specific task. It provides the reusability of code. We can also easily modify code using methods. In this section, we will learn what is a method in Java, the types of methods, method declaration, and how to call a method in Java.
A method is a block of code or collection of statements or a set of codes grouped together to perform a certain task or operation. It is used to achieve the reusability of code. We write a method once and use it many times. We do not require to write code again and again. It also provides the easy modification and readability of code, just by adding or removing a chunk of code. The method is executed only when we call or invoke it
The most important method in Java is the main() method.
------------------------------------------------------------------------------
There are two types of methods in Java:
Predefined Method
User-defined Method
Predefined Method
-------------------------------------------------
In Java, predefined methods are the method that is already defined in the Java class libraries is known as predefined methods. It is also known as the standard library method or built-in method. We can directly use these methods just by calling them in the program at any point. Some pre-defined methods are length(), equals(), compareTo(), sqrt(), etc. When we call any of the predefined methods in our program, a series of codes related to the corresponding method runs in the background that is already stored in the library.
Each and every predefined method is defined inside a class. Such as print() method is defined in the java.io.PrintStream class. It prints the statement that we write inside the method. For example, print("Java"), it prints Java on the console.
2) User-defined Method
---------------------------------------------------------------------------------
The method written by the user or programmer is known as a user-defined method. These methods are modified according to the requirement.
----------------------------------------------------------------------------------
Once we have defined a method, it should be called. The calling of a method in a program is simple. When we call or invoke a user-defined method, the program control transfer to the called method.
Can call the method using Object/Class name


Object.method_name(); // Non-static method
Class_name.method_name(); // static method
------------------------------------------------------------------------------


Auf dieser Seite können Sie das Online-Video Video-23 Method in JAVA | what is the method/function mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Explore More 01 Januar 1970 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 17 Mal angesehen und es wurde von 2 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!