An array is a collection of similar types of elements stored in a contiguous memory location. The following section contains various programs on Arrays with examples like array operations, types of array, single-dimensional array, sort, and merging operations, mathematical functions on arrays, and array data structures. It also covers programs on insertion and deletions of elements in an array.
Each sample program includes a program description, Java code, and program output. All examples have been compiled and tested on Windows and Linux systems.
Here is the listing of Java programming examples on Arrays:
- Java Programs on Largest & Smallest Numbers in an Array
- Java Programs on Inserting & Deleting Elements from an Array
- Java Programs to Perform Operations on Arrays
- Java Programs on Printing the Elements of an Array
- Single Dimensional Array Programs in Java
- Java Programs on Sort & Merge Operations on an Array
- Java Programs on Math Functions and their Applications on Arrays
- Array Data Structure in Java
- More Array Programs in Java
1. Java Programs on Largest & Smallest Numbers in an Array
Program | Description |
---|---|
Find Number of Elements in an Array in Java | Java Program to Find the Number of Elements in an Array |
Largest Element in Array in Java | |
Find Largest Two Numbers in Array in Java | Java Program to Find Largest Two Numbers in an Array |
Second Largest & Smallest Element of an Array in Java | Java Program to Find Second Largest and Smallest Elements in an Array |
Print Next Greater Element in Array in Java | Java Program to Print Next Greater Element in Array |
Find Min Distance b/w Array Elements in Java | Java Program to Find the Minimum Distance between Array Elements |
Maximum Difference b/w Two Elements in Java | Java Program to Find Maximum Difference Between Two Elements in an Array |
advertisement
2. Java Programs on Inserting & Deleting Elements from an Array
Program | Description |
---|---|
Insert an Element in an Array in Java | Java Program to Insert an Element in an Array |
Remove Duplicates from Sorted Array in Java | Java Program to Remove Duplicate Elements from Array |
Delete an Element from an Array in Java | Java Program to Delete an Element from an Array |
Separate Odd & Even Numbers from an Array in Java | Java Program to Separate Odd and Even Numbers from an Array |
Replace Element with Greatest Element on Right Side in Java | Java Program to Replace Elements with Greatest Element on Right Side |
Cyclically Permute the Elements of an Array in Java | Java Program to Cyclically Permute the Elements of an Array |
3. Java Programs to Perform Operations on Arrays
Program | Description |
---|---|
Rotate Array in Java | Java Program to Rotate an Array by n Elements |
Search an Element in an Array in Java | Java Program to Search Key Elements in an Array |
Sum of Array Elements in Java | Java Program to Find Sum of Array Elements |
Sum & Average of Array Elements in Java | Java Program to Find Sum and Average of All Elements in an Array |
Smallest Positive Number Missing from Array in Java | Java Program to Find the Smallest Positive Number Missing from an Unsorted Array |
Frequency of all Duplicate Elements in an Array in Java | Java Program to Find the Frequency of All Duplicate Elements in an Array |
Non Repeated Elements in an Array in Java | Java Program to Print All Non Repeated Elements in an Array |
Find Missing Numbers in Array in Java | Java Program to Find Missing Numbers in Array |
Find Missing Element in an Integer Array in Java | Java Program to Find the Missing Element in an Integer Array |
Segregate 0s & 1s in an Array in Java | Java Program to Segregate 0s and 1s in an Array |
Increment an Array by One in Java | Java Program to Increment All Elements of an Array by One |
Count No of Occurrences in an Array in Java | Java Program to Count the Number of Occurrence of an Element in an Array |
4. Java Programs on Printing the Elements of an Array
Program | Description |
---|---|
Odd & Even Numbers in an Array in Java | Java Program to Print Even and Odd Numbers in an Array |
Find Even Occurring Elements from Array in Java | Java Program to Find the Number Occurring Even Number of Times |
Find Odd Occurring Elements from Array in Java | Java Program to Find the Number Occurring Odd Number of Times |
Kth Largest Element in an Array in Java | Java Program to Find the kth Element in an Array |
Print Even Numbers at Even Index in Java | Java Program to Print Even Elements at Even Index Number |
Print Even Numbers at Odd Index in Java | Java Program to Print Even Elements at Odd Index Number |
Print Odd Numbers at Even Index in Java | Java Program to Print Odd Elements at Even Index Number |
Print Odd Numbers at Odd Index in Java | Java Program to Print Odd Elements at Odd Index Number |
Leaders in an Array in Java | Java Program to Print All the Leaders in an Array |
Find Pair with Difference in Java | Java Program to Find a Pair of Elements with the Given Difference |
Longest Increasing Subarray in Java | Java Program to Print the Longest Increasing Subarray |
Longest Decreasing Subarray in Java | Java Program to Print the Longest Decreasing Subarray |
5. Single Dimensional Array Programs in Java
Program | Description |
---|---|
Find Total Marks & Percentage using Array in Java | Java Program to Find Total Marks and Percentage using 1D Array |
6. Java Programs on Sort & Merge Operations on an Array
Program | Description |
---|---|
Sort the Array in Ascending Order in Java | Java Program to Sort an Array in Ascending Order |
Sort the Array in Descending Order in Java | Java Program to Sort an Array in Descending Order |
Sort Names in Alphabetical Order in Java | Java Program to Sort N Names in an Alphabetical Order |
Merge Two Arrays in Java | Java Program to Merge Two Arrays |
Merge Two Arrays without Extra Space in Java | Java Program to Merge Two Arrays Without Extra Space |
Split an Array from Specified Position | Java Program to Split an Array from Specified Position |
Split an Array & Add First Part to the End in Java | Java Program to Split the Array and Add First Part to the End |
Move All Zeroes to Beginning of Array in Java | Java Program to Move All Zeros to the Start of an Array |
Move All Zeroes to End of Array in Java | Java Program to Move All Zeros to the End of an Array |
7. Java Programs on Math Functions and their Applications on Arrays
Program | Description |
---|---|
Union & Intersection of 2 Arrays | Java Program to Find Union and Intersection of Two Arrays |
Check Pythagorean Triplets in Java | Java Program to Find Pythagorean Triplets in an Array |
8. Array Data Structure in Java
Program | Description |
---|---|
Bit Array in Java | Java Program to Implement Bit Array |
Dynamic Array in Java | Java Program to Implement Dynamic Array |
Variable Length Array in Java | Java Program to Implement Variable Length Array |
Sorted Array in Java | Java Program to Implement Sorted Array |
Sparse Array in Java | Java Program to Implement Sparse Array |
Suffix Array in Java | Java Program to Implement Suffix Array |
Associate Array in Java | Java Program to Implement Associate Array |
Array Deque in Java | Java Program to Implement Array Deque |
9. More Array Programs in Java
Program | Description |
---|---|
Sum of Two Numbers is Equal to Given Number In Java | Java Program to Find Two Elements whose Sum is Equal to a Given Number |
Closest to Zero Program in Java | Java Program To Find Two Elements whose Sum is Closest to Zero |
Find Address of an Array in Java | Java Program to Find the Address of an Array |
Find Local Minima in an Array in Java | Java Program to Find Local Minima in an Array |
Find Local Maxima in an Array in Java | Java Program to Find Local Maxima in an Array |
Largest Subarray with 0s & 1s in Java | Java Program to Find the Largest Subarray with Equal Number of 0s and 1s |
Smallest Sum Contiguous Subarray in Java | Java Program to Find the Minimum Sum in a Contiguous Sub-Array |
Java Program to Check if an array is Increasing | Java Program to Check if an Array is Increasing |
Java Program to Check if an array is Decreasing | Java Program to Check if an Array is Decreasing |
Dutch National Flag Problem in Java | Java Program to Solve the Dutch National Flag Problem |
Codility Passing Car Problem in Java | Java Program to Solve the Passing Car Codility Problem |