Check out example codes for "how to do a linear searc in java". It will help you in understanding the concepts better.

Code Example 1

public static int linear(int[] arr, int keyValue)
{
  int pos = -1; 

    for (int i = 0; i < arr.length; i++)
    {
        if (arr[i] == keyValue)
        {
            pos = i;
            break;
        }
	}
	return pos;
}

Learn ReactJs, React Native from akashmittal.com