Linear Search in Java

If you want to practice data structure and algorithm programs, you can go through Java coding interview questions.

In this post, we will see about linear search in java.

Linear search is simple sequential search in which target element is searched one by one in the array. If element is found in the array then index will be returned else -1 will be returned.
Here is simple program for linear search.

Output:

Element found at position 5

That’s all about linear search in java.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *