Java Program:

- To Create a function to add 2 numbers

Example:

User Input: 2,3

Output: 5

import java.util.Scanner;
public class SumNummber {

  public static int sum(int n1,int n2) {
      return n1+n2;
    }

  public static void main(String []args) {
    int n1,n2;
    Scanner userInput = new Scanner(System.in);
    System.out.print("Enter two numbers : ");
    n1 = userInput.nextInt();
    n2 = userInput.nextInt();
    
    System.out.print("Sum : "+sum(n1,n2));
  }
}

Output:

  Enter two numbers : 7
  5
  Sum : 12
Program
basic
//function to add 2 numbers
public static int sum(int n1,int n2){
  return n1+n2;   //use add(+) operator
}

Since, function returns integer data type, so we declare int just before the function name

For devision (/), subtraction (-), multiplication (*), you can use their respective operators

Concept

Coming Soon !

Quick
Tutorial

Quote

We are all now connected by the Internet, like neurons in a giant brain.