Check Array Value in Java
This post is for finding out, whether a particular value is present in an array or not.
Array : Array is a collection of similar type of elements, stored along a contiguous memory location.
dataType  variable_name;
int  arr;
This is an array of int dataType.
Now, let's see the code to find a specific value in an array. Here code will check whether the value "Tony" is present in the given array of Strings or not.
1. Using for loop :This is the most simple method. Here a for loop will rotate over the array, in which a string named as 'str' will have the value that we wish to find from the array. If the value is found, message will be printed as value found.Here is the code :