Methods in Java
Java Methods are collections of statements that perform some specific task and return the result.
Syntax of Method
<access_modifier> <return_type> <method_name>( list_of_parameters)
{
//body
}
Below is the implementation of the above method:
Java
// Java Program to demonstrate the // Use of Methods import java.io.*; // Driver Class class GFG { public static int sum( int i, int j) { return i + j; } // main method public static void main(String[] args) { int n = 3 , m = 3 ; for ( int i = 0 ; i < n; i++) { for ( int j = 0 ; j < m; j++) { System.out.print(sum(i, j) + " " ); } System.out.println(); } } } |
0 1 2 1 2 3 2 3 4
Java Cheat Sheet
Java is a programming language and platform that has been widely used since its development by James Gosling in 1982. It follows the Object-oriented Programming concept and can run programs written in any programming language. Java is a high-level, object-oriented, secure, robust, platform-independent, multithreaded, and portable programming language All those words are collectively called Java Buzzwords. It is commonly used for programming web-based, window, enterprise, and mobile applications. This Java Cheat Sheet article has been written by experts in Java and based on the experience of students who have recently undergone Java interviews.
This Core Java Cheat Sheet has been designed by Java experts, based on the experience of students who have recently undergone Java interviews. Whether you are a beginner or an experienced Java developer, this Java Cheat Sheet is a valuable resource for quickly accessing essential syntax, concepts, and best practices related to Java Programming.