Create a Java program with a method that searches an integer array for a specified integer value (see help withstartingthe method header below). If the array contains the specified integer, the method should return its index in the array. If not, the method should throw an Exception stating "Element not found in array" and end gracefully. Test the method in main with an array that you make and withuser input for the "needle".public static int returnIndex(int[ ] haystack, int needle) {
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here