Beginners Programs :

Java Program Addition Of Two Numbers – 4 Ways | Programs

Java program to print or calculate addition of two numbers with sample outputs and example programs. Addition of two numbers program is quite a simple one, we do also write the program in five different ways using standard values, command line arguments, classes and objects, without using addition+ operator, method, BufferedReader with sample outputs and code.

  • How to add numbers?

Well, do you really need an explanation for this? I think not.

  • Let’s get into the programming part.

Java Program To Print Addition Of Two Numbers

1. Standard Method Function


2. Using command line arguments 

There you go another method using command line arguments : If you have no idea about what are command line arguments in Java. Do check it out complete guide here – what are command line arguments in java with examples.


3. Using classes and Objects

Print addition of numbers : Another sample program using objects and classes


4. Without Using Addition+ Operator

You can even write the program without using the + operator here is the sample code – Learn more about what are different types of operators in Java with examples.


5. Using Method

Example program #5 : Using method calling to print the addition of two numbers.


6. Using Buffered Reader

To Print addition of numbers using BufferedReader with sample output.


For You:

Here is the list of other programs for you:


  1. Hi,

    Very useful article on addition program in java. Thanks for sharing.


  2. public class Function {

    int r;
    int addition(int a,int b){

    return r;
    public static void main(String[] args) {

    Function z=new Function();

    System.out.println(“The function is: “+z.r);


  3. Added two numbers used for do-while
    loop.write or not tell me our suggestion s

  4. how would you add three numbers togethere in java

  5. Add two numbers without using third variable. Sum etc .

Leave a Reply

Your email address will not be published. Required fields are marked *