**Java version of this program is given below :**

public class Random { public static int a[]; public int l; public static int integer(int from, int to){ return (int) Math.round(Math.random()*(to-from))+from; } public void array(){ int k=integer(2000,5000); a=new int[k]; for(int i=0;i<k;i++){ a[i]=integer(2000,5000); } } public int get_key(){ int key=integer(2000,5000); int index=-1; for(int j=0;j<a.length;j++){ if(a[j]==key) { index=j;break; } } return index; } public static void main (String args[]){ Random n=new Random(); n.array(); System.out.println("Array length is ="+a.length+"....." +"Get the key index ="+n.get_key()); } }