Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

Recommend the key methods to improve service productivity.

Answered: 1 week ago