Practice Arrays in Java
Work with arrays including creation, traversal, searching, and sorting algorithms.
Work through 22 exercises with starter code, expected output, test cases, and hints.
Arrays exercises
- Declare and Print Array Java exercise — Create and display array elements
- Sum of Array Java exercise — Calculate the sum of array elements
- Find Maximum Java exercise — Find the largest element in an array
- Calculate Average Java exercise — Find the average of array elements
- Count Even Numbers Java exercise — Count even numbers in an array
- Linear Search Java exercise — Find an element in an array
- Reverse Array Java exercise — Reverse an array in place
- Second Largest Element Java exercise — Find the second largest element
- Remove Duplicates Java exercise — Remove duplicate elements from array
- Rotate Array Java exercise — Rotate array elements to the right
- Merge Sorted Arrays Java exercise — Merge two sorted arrays into one sorted array
- Bubble Sort Java exercise — Implement bubble sort algorithm
- Selection Sort Java exercise — Implement selection sort algorithm
- Binary Search Java exercise — Implement binary search on sorted array
- Find Pair with Sum Java exercise — Find two numbers that add up to target
- Maximum Subarray Sum Java exercise — Find the maximum sum of a contiguous subarray
- Leaders in Array Java exercise — Find all leaders in an array
- Equilibrium Index Java exercise — Find index where left sum equals right sum
- Wave Array Java exercise — Convert array to wave form
- Majority Element Java exercise — Find element appearing more than n/2 times
- Left Rotate Array Java exercise — Rotate array elements to the left by k positions
- Find Leaders Java exercise — Find elements greater than all elements to their right
Browse the complete Java practice path · Open the online Java compiler