Java Program to find the product of two integer numbers

How to create a class in java?

Here we are explaining how to write a java program to find the product of two integer numbers So first we have to declare the class ProductOfTwoNumbers with a public modifier. An Example of a class declaration is shown below.




Here the name of the class is ProductOfTwoNumbers and the modifier is public.


How the product of two integer numbers is implemented in java?

First, we have to declare the class ProductOfTwoNumbers then we open the main() function. Then we declare n1,n2, product as datatype integer.Then we set n1=10,n2=2..Then we perform the multiplication as product=n1*n2. Now the value of the product becomes 20. Then we can display the product of two numbers as the value of the product using System.out.println.


STEP 1: Declare the class ProductOfTwoNumbers with a public modifier 

STEP 2: Open the main() to start the program, Java program execution starts with the main() function.

STEP 3: Declare the variables n1,n2,product as integer.

STEP 4: Assign n1=10,n2=2.

STEP 5: Calculate the product as n1*n2.

STEP 6: Display the product using System.out.println.

Java Source Code

                                          public class ProductOfTwoNumbers { 

   public static void main(String[] args) {
      int n1=10,n2=2,product;//Declare the variables.
      product=n1*n2;//Calculate the product.

      System.out.println("Product of two integer numbers: "+product);//Display the product


Product of two integer numbers: 20