By Editorial Staff. Updated on
In this program, we are going to share a Java program to add two numbers using Pointer with the output. If you are a Java beginner and want to start learning the Java programming, then keep your close attention in this tutorial as I am going to share how to write a Java program to add two numbers using Pointer.
To increase your Java knowledge, practice all Java programs:
Copy the below Java program and execute it with the help of Javac compiler. At the end of this program, We have shared the output of this program.
public int value;
public class JavaProgram
public static void main(String args)
int num1, num2, sum=0;
Scanner scan = new Scanner(System.in);
System.out.print("Enter Two Number : ");
num1 = scan.nextInt();
num2 = scan.nextInt();
ptr1 = new IntObj();
ptr2 = new IntObj();
ptr1.value = num1;
ptr2.value = num2;
sum = ptr1.value + ptr2.value;
System.out.print("Sum of the Two Number is " +sum);
Enter the two number :1025
Sum of the two number is 35
Sharing is caring!