- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
Java is a versatile and widely-used programming language, known for its simplicity and portability. Practicing Java programming through examples is an effective way to learn and master the language. Here are some common Java programming examples that cover basic to advanced concepts.
Basic Java Programs
1. Hello World Program
The simplest Java program that prints "Hello, World!" to the console.
public class HelloWorld {public static void main(String[] args) {System.out.println("Hello, World!");}}Copied!✕Copy2. Add Two Numbers
A program to add two integers.
import java.util.Scanner;public class AddTwoNumbers {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);System.out.print("Enter first number: ");int num1 = scanner.nextInt();System.out.print("Enter second number: ");int num2 = scanner.nextInt();int sum = num1 + num2;System.out.println("Sum: " + sum);}}Copied!✕Copy3. Check Even or Odd
A program to check whether a number is even or odd.
Java Examples - Programiz
The best way to learn Java programming is by practicing examples. The page contains examples on basic concepts of Java. You are advised to take the references from these examples and try them on …
See results only from programiz.comJava Program to Check Whet…
In this program, you'll learn to check whether a given number can be …
Java Program to Reverse a S…
In this program, you'll learn to reverse a given sentence using a recursive loop in …
Java Program to Find Ascii V…
In simple terms, casting is converting a variable from one type to another, here …
Java Program to Get Current …
In this program, you'll learn to get the current date and time in different formats …
Java Program to Find All Roo…
In this program, you'll learn to find all roots of a quadratic equation and print them …
Java Program to Concatenat…
In this program, you'll learn to concatenate two arrays in Java using arraycopy and …
Java Program to Display Arm…
In this program, you'll learn to display all armstrong numbers between two given …
Java Program to Check Palin…
A string that is equal to the reverse of that same string is called a palindrome string …
Java Program to Convert Ch…
In this program, you'll learn to convert a character (char) to a string and vice …
Java Program to Find Fact…
In this program, you'll learn to find the factorial of a number using for and while …
Java Programs - Java Programming Examples
Sep 25, 2025 · This page covers Java programming examples from basics like Fibonacci, Prime numbers, Factorials and Palindromes to advanced topics such …
Java Examples - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
Java Programs – 500+ Simple & Basic Programs With …
Feb 25, 2026 · Java programs: Basic Java programs with examples & outputs. Here we covered over the list of 500+ Java simple programs for beginners to advance, …
Java Program Examples - Tutorial Gateway
For all these simple and basic Java programs, we provide multiple examples (ways to find the solution) using for loop, while loop, do while, recursion, functions, and …
100+ Java Programs for Practice
Whether you are preparing for Java exams, coding interviews, competitive programming, or improving your core programming skills, these Java practice …
50 simple java programs for beginners | Java …
Mar 26, 2021 · Can you write a program to check whether a number is prime number or not? Ans. Check for all the numbers below the given number that any …
35 Basic Java Program Examples with Outputs | Simple …
Oct 30, 2025 · Java Simple Program for Beginners demonstrates the fundamental structure of a Java application, including class declaration, main() method, and …
Java Programs – Java Programming Examples with Output
Nov 28, 2022 · This page includes java programs on various java topics such as control statements, loops, classes & objects, functions, arrays etc. All the programs are tested and provided with the output.
Java Programs (Code Examples With Output)
New to Java? Kickstart your learning with simple Java programs, step-by-step examples, clear output, and beginner-friendly explanations.
Related searches for Example of Java Simple Program