Last Updated:

The software to search for the elements in the array. Example in Java

Find an element in an array. Program in Java

Our program implements a linear search algorithm.

Linear or sequential search is the simplest way to find an element in an array of numbers. The search occurs alternately by comparing the element of the entire array.

Below is a Java program for searching for elements in an array in a simple search:

Note that in the above program we used the break statement.

The result of running a Java program to search for an element in an array:

An example of an unsuccessful item search:

If you liked this article for novice Java developers, then you will surely like the other articles in the Getting Started section.