Practice Java with hands-on exercises designed to reinforce key concepts across all modules and difficulty levels. From beginner fundamentals to advanced topics, each exercise helps you apply what you’ve learned through real coding scenarios.

Use the filters to quickly find exercises by module and level, focus on specific areas, and progress at your own pace. Each exercise includes clear objectives, input/output examples, and starter code(when applicable) to guide your implementation.

Build your skills, gain confidence, and move from theory to practice with structured, real-world Java exercises.

Text Processing
Intermediate

Most Frequent Character

Return the most frequent character in a string.

Input:
aabbbc
Output:
b
Explanation: 'b' appears 3 times
Text Processing
Intermediate

Check Anagram

Check if two strings are anagrams.

Input:
listen,  silent
Output:
TRUE
Explanation: both strings contain the same characters in a different order
Text Processing
Beginner

Reverse String

Reverse a string without using a loop.

Input:
java
Output:
avaj
Explanation: the string is reversed from left to right
Text Processing
Beginner

Count Vowels

Count the number of vowels in a string.

Input:
hello
Output:
2
Explanation: the vowels are 'e' and 'o'
Text Processing
Beginner

String Length Without Built-in

Compute the length of a string without using length().

Input:
hello
Output:
5
Explanation: the string 'hello' contains 5 characters
Arrays and Loops
Intermediate

Flatten 2D Array

Convert a 2D array into a single list where each item preserves its position.

Input:
[[1,2],[3,4]]
Output:
[1,2,3,4]
Explanation: rows are concatenated in order
Arrays and Loops
Intermediate

Rotate Array Right

Rotate an array to the right by one position.

Input:
[1,2,3,4]
Output:
[4,1,2,3]
Explanation: the last element moves to the front
Arrays and Loops
Intermediate

Find Duplicate Element

Return the first duplicate value in an array.

Input:
[1,2,3,2]
Output:
2
Explanation: it is the first repeated value
Arrays and Loops
Intermediate

Diagonal Sum Matrix

Compute the sum of the main diagonal of a square matrix.

Input:
[[1,2],[3,4]]
Output:
5
Explanation: 1 + 4 = 5
Arrays and Loops
Intermediate

Matrix Row Sum

Compute the sum of each row in a 2D array.

Input:
[[1,2],[3,4]]
Output:
[3,7]
Explanation: 1+2=3 and 3+4=7