Java program to add two numbers. Addition in java.

 Addition program in java 

In this tutorial we are going to discuss about how to add two integer value in java
or a simple addition program in java. 

Lets go ,


Define:-First we have to declare class

Thereafter make two integer type of variable (num1 and num2 )and add this to another integer type variable name (result)

int num1=10,num2-20,result;

result=num1+num2;

This is the logic to do a simple addition program in java.

 Approach :-1

Output :-75



Approach:-2

Define:-It is the second approach to add two numbers without using (String []args) 

Let's know how this could happen. 

In java there is method known as var-arg method. Using this method we add two no. 

Let's see the code

 

Output:-75



0 K comment

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel