Java Online Compiler
Example: Java program to demonstrate find the sum of two integer values
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Java program to demonstrate find the sum of two integer values import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter two integer values::\n"); // Reading integer data using nextInt int p = in.nextInt(); int q = in.nextInt(); int r; r = p + q; System.out.println("\n\nResult:: " + p + " + " + q + " = " + r); } }
5 7
Output
Clear
ADVERTISEMENTS