Finally got help from my tutor.This is one possible way to do it.
import java.util.*;
public class ArrayTest{
public static void main (String[]args){
Scanner input = new Scanner(System.in);
int [] number = new int[5];
int numberToSearchFor;
int i;
boolean found=false;
for (i=0; i<number.length;i++){
number [i] = (int)(Math.random()*20)+1;
System.out.println(number[i]);
}
System.out.println("Enter number to find from available numbers: ");
numberToSearchFor = input.nextInt();
i=0;
while(!found&&i<number.length)
if (number[i] == numberToSearchFor){
System.out.println("Found it at index " + i);
found=true;
}
else
i++;
if(!found)
System.out.println("Cannot find it");
}
}