- Java Tutorial
 - Java Introduction
 - Java Features
 - Java Simple Program
 - JVM, JDK and JRE
 - Java Syntax
 - Java Comments
 - Java Keywords
 - Java Variables
 - Java Literals
 - Java Separators
 - Java Datatypes
 - Java Operators
 - Java Statements
 - Java Strings
 - Java Arrays
 - Control Statement
 - Java If
 - Java If-else
 - Java If-else-if
 - Java Nested If
 - Java Switch
 - Iteration Statement
 - Java For Loop
 - Java For Each Loop
 - Java While Loop
 - Java Do While Loop
 - Java Nested Loop
 - Java Break/Continue
 - Java Methods
 - Java Methods
 - Java Method Parameters
 - Java Method Overloading
 - Java Recursion
 - Java OOPS
 - Java OOPs
 - Java Classes/Objects
 - Java Inheritance
 - Java Polymorphism
 - Java Encapsulation
 - Java Abstraction
 - Java Modifiers
 - Java Constructors
 - Java Interface
 - Java static keyword
 - Java this keyword
 - Java File Handling
 - Java File
 - Java Create File
 - Java Read/Write File
 - Java Delete File
 - Java Program To
 - Add Two Numbers
 - Even or Odd Numbers
 - Reverse a String
 - Swap Two Numbers
 - Prime Number
 - Fibonacci Sequence
 - Palindrome Strings
 - Java Reference
 - Java String Methods
 - Java Math Methods
 
Java Program To Add Two Number
Here's a simple Java program to add two numbers entered by the user:
import java.util.Scanner;
public class AddTwoNumbers {
    public static void main(String[] args) {
        // Create a Scanner object to read input from the user
        Scanner scanner = new Scanner(System.in);
        // Prompt the user to enter the first number
        System.out.print("Enter the first number: ");
        double num1 = scanner.nextDouble();
        // Prompt the user to enter the second number
        System.out.print("Enter the second number: ");
        double num2 = scanner.nextDouble();
        // Close the Scanner object to prevent resource leak
        scanner.close();
        // Add the two numbers
        double sum = num1 + num2;
        // Display the result
        System.out.println("The sum of " + num1 + " and " + num2 + " is: " + sum);
    }
}
In this program:
- We use the Scanner class to read input from the user.
 - We prompt the user to enter two numbers.
 - We read the input numbers using the nextDouble() method of the Scanner class.
 - We add the two numbers and store the result in a variable called sum.
 - Finally, we display the sum of the two numbers to the user.