In general, the simplest methods are the best. For example:
public static int search(int arr[], int x)
{
int n = arr.length;
for (int i = 0; i < n; i++)
{
...