60 475
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #2155 in Java | JSP | JSF for Array method

Question #2155
Create a method called findElementIndex, which takes an integer and an integer array as input parameters, and returns the smallest index where that value appears. If the value is not in the array, the method should return -1.

Example:
value: 3 theArray:{10, 3, 6, 3, 8, 10} ==> 1
value:10 theArray:{11, 3, 6, 7, 9, 60} ==> -1



Expert's answer
public static int findElementIndex(int fi, int[] arr){
for(int i = 0; i < arr.length; ++i)
if (arr[i] == fi)
return i;
return -1;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions