Question: Write a method findElementIndex which takes an integer array and another integer as arguments and returns an index value if the array (first parameter) contains

Write a method findElementIndex which takes an integer array and another integer as arguments and returns an index value if the array (first parameter) contains an element which is equal to to the integer (second parameter). If there is more than one element with the same value, the method should return the first (smallest) index value that contains the element. If the array does not contain an element with the given value, the method should return -1. For example, given the array {13, -1, 12} and the number 12 the method would return 2 because the number 12 is at index 2. {12, -1, 12} and 12 would return 0 because 12 is first found at index 0. On the other hand, {13, -1, 20} and 12 would return -1. If an array has no elements, the array doesn't contain the element you're looking for so the method should return false.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!