☕ Java Programs
105 Essential Programs from Beginner to Advanced
Your Progress
Filter by Category
Filter by Level
Hello World
#1Print Hello World
Print Name
#2Print user name
Add Two Numbers
#3Add two numbers
Swap Numbers
#4Swap two variables
Largest of Two
#5Find largest of two numbers
Even or Odd
#6Check even or odd
Factorial
#7Find factorial of number
Fibonacci
#8Print Fibonacci series
Reverse Number
#9Reverse digits of number
Prime Check
#10Check if number is prime
Palindrome String
#11Check palindrome string
Sum of Array
#12Find sum of array elements
Largest in Array
#13Find largest element
Count Vowels
#14Count vowels in string
Sum of Digits
#15Sum digits of a number
Leap Year
#16Check if year is leap year
ASCII Value
#17Find ASCII value of a character
Armstrong Number
#18Check Armstrong number
Multiplication Table
#19Print multiplication table
Vowel or Consonant
#20Check if char is vowel
Reverse Array
#21Reverse an array
Binary Search
#22Binary search
Anagram Check
#23Check if strings are anagrams
Constructor Overloading
#24Multiple Constructors
Method Overriding
#25Overriding parent methods
ArrayList Basics
#26Using ArrayList
HashMap Basics
#27Using HashMap
Exception Handling
#28Try / Catch
Custom Exception
#29Throw custom exception
Read Text File
#30Read using Scanner
Lambda Expression
#31Java 8 Lambda
Streams Map/Filter
#32Java 8 Streams
String to Int
#33Parsing string
Sort Array of Objects
#34Using Comparable
Thread Basics
#35Create a thread
Runnable Interface
#36Implement Runnable
Deadlock Example
#37Simulate deadlock
Singleton Pattern
#38Singleton instance
Factory Pattern
#39Factory design pattern
Generics
#40Generic class
Record Classes
#41Java 14+ Records
Reflection API
#42Get class name at runtime
Annotations
#43Custom Annotation
CompletableFuture
#44Async operations
Quick Sort Java
#45Quick sort algorithm
Merge Sort Java
#46Merge sort algorithm
Linked List Node
#47Custom LinkedList
Binary Tree Traverse
#48Inorder traversal
JDBC Connection
#49Database connection
TCP Socket
#50Client Server basic
Lambda Map Reduce
#51Stream map and reduce
Method Reference
#52Double colon operator
Optional Basics
#53Avoid null checks
Switch Expression
#54Java 12+ Switch
Text Blocks
#55Multiline strings
Var Keyword
#56Local variable inference
Pattern Matching
#57instanceof pattern
Stack implementation
#58Using Java Stack
Queue implementation
#59Using LinkedList as Queue
HashSet Basics
#60Unique elements
TreeSet Sorting
#61Sorted Unique elements
TreeMap
#62Sorted Map by key
Comparator Interface
#63Custom sorting
Iterator
#64Iterating Collections
Create Thread (Runnable)
#65Thread using Runnable
Thread Sleep
#66Pause a thread
Thread Join
#67Wait for thread death
Synchronized Block
#68Thread safety
ReentrantLock
#69Advanced locking
Executors
#70Thread pool execution
Callable & Future
#71Return result from thread
CountDownLatch
#72Wait for multiple threads
CyclicBarrier
#73Sync threads at point
Read/Write Lock
#74Concurrent reads
Write to File
#75Using Files.write
Read all lines
#76Using Files.readAllLines
File Copy
#77Using Files.copy
List Directory
#78Using Files.list
Delete File
#79Using Files.delete
Properties File
#80Read key value pairs
Serialization
#81Object to Byte stream
Deserialization
#82Byte stream to Object
Abstract vs Interface
#83Basic usage
Polymorphism Basics
#84Overridden methods
Super Keyword
#85Access parent class
Enum Basics
#86Custom Enums
Enum with values
#87Constructor in Enum
Inner Class
#88Class inside class
Anonymous Inner Class
#89Class without name
Try with Resources
#90Auto close resources
Custom Exception
#91Inherit Exception
Chained Exceptions
#92Exception cause
Assertion
#93Using assert keyword
Dynamic Proxy
#94Proxy class
ProcessBuilder
#95Run external commands
HttpClient (Java 11+)
#96Modern HTTP request
Graph Implementation
#97Adjacency List Graph
Dijkstra shortest path
#98Using PriorityQueue
Builder Pattern
#99Design Pattern
Decorator Pattern
#100Design Pattern
Strategy Pattern
#101Design Pattern
JDBC ResultSet
#102Read DB rows
JNI Basics
#103Java Native Interface
ClassLoader
#104Custom class loader
Unsafe API
#105sun.misc.Unsafe hack
