Question 4 5 points You have an int array named examScore th

Question 4 (5 points)

You have an int array named examScore that is 100 elements in length.
Provide a single line of code that would search the examScores for values that
are 50.

(Note: You do not need to provide the import statements supporting the line of code)

Solution

for(int i=0;i<100;i++)

{

if(examScore[i]==50)

System.out.println(\"\" + i);

}

Or

Convert the array to an array list or hashset and use the contains() method to search for the element.

List<String> l = Arrays.asList(examScore);. // convert array to array list or list

l.contains(50); // to search for the element in the list

Question 4 (5 points) You have an int array named examScore that is 100 elements in length. Provide a single line of code that would search the examScores for v

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site