Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Array HayStack Program Objective: Understand how to pass arrays via parameters 1. Class HayStack 2. In the main method, create an array called arrHayStack that

image text in transcribed

Array HayStack Program Objective: Understand how to pass arrays via parameters 1. Class HayStack 2. In the main method, create an array called arrHayStack that holds a minimum 10 elements. All the elements except one hold the String value hay". One array element contains the String "needle". 3. Write a method named findNeedle ) findNeedle receives the arrHaystack array in its parameter 4. findNeedle method uses a for loop to find the array element that contains the String needle" Once it is found the index for that element is returned. 5. In the main method, invoke findNeedle method and replace the String 'needle' with the String 'found', print the modified array IMPORTANT: You can't compare Strings with == that only compares reference of the Strings. You NEED to use a method called equals example: (if string1.equals(string2)) Sample Output: Needle found in Haystack in arrHaystack [1] old Hay Stack: hay needle hay hay hay hay hay hay hay hay New Hay Stack: hay found hay hay hay hay hay hay hay hay

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions