Arrays in Java are a powerful way to store multiple elements of Similar type. You can read more about them here (Arrays in Java). You can also refer to the official Oracle documentation for more information.
Since the advancement in Java version there are many utility functions that has made the manipulations and working with Arrays simpler. java.util.Arrays
library provide many such util functions. There is another library that provides more advance utility functions for Array manipulations org.apache.commons.lang3.ArrayUtils
.
Below are the beginner as well as advanced level practice questions that involves Java Arrays concept. Although there are solutions given next to each of the question, we recommend that you come up with your own solution and only check the our solution to compare the approach.
Even though many of the below questions can easily be solved by using utility library methods, it would be better to approach with your own solution to understand how arrays are implemented internally.
Good Luck !
Exercise Questions
- Java Program to find average of an int Array. [ Solution Program : Calculate Average of Array Elements in Java ]
- Create a Java Program to Sort an Array of Numeric or String Data. [Solution : Program : Sort an Array in Java]
- Write a Java Program to check if see if Array contains a specific value. [Solution: Program : To check if Array contains an specific element. (Primitive value)]
- Write a Java Program to reverse the array contents. [Solution: Program: Java Code to Reverse an int Array]
- Write a Java Program to remove a particular element from an array. [Solution : Program : Remove an Element from int Array in Java]
- Write a Java Program to find the second highest value in a numeric array. [Solution: Java program to find second largest number in an array ]
- Create a Java code to copy an Array into another array. [Solution: Java Code to Copy Array into Another Array ]
- Write a Java Code a Array of length 100 and fill it with Random int Values for testing purpose. [Solution: Java Code to fill int / double Array with random values. ]
- Java program to find duplicate elements in an String array. [Solution: Code to find duplicate elements in an String array.]
- Write a Java program to check if two arrays are equal. [Solution : Java Program to check if two arrays are Equal ]
- Implement a Stack Data-Structure in Java using Arrays. [ Solution : Stack Implementation in Java]
- Implement a Queue Data-Structure in Java using Arrays. [Solution : Queue Implementation in Java]