Arrays Of Strings

22 Dec No Comments

Arrays Of Strings

 Write a method named find. The method shall take two arguments. And  array of strings and a string t, for the target. Your method shall return true if the target t appears in the array, false otherwise. (note you will have to create a new array of strings 

class Main {

public static boolean find(String[] myStringArray, String t) {

for (String element:myStringArray ) {

if (element.equals(t)) {

return true;

}

}

return false;

}

public static void main(String[] args)

{

boolean found=find(new String[] {“Car”,”Plane”,”Bike”,”Train”},”Bike”);

if (found) {

System.out.println(“String found”);

} else {

System.out.println(“String not found”);

}

}

}




Click following link to download this document

Arrays Of Strings.docx

Would you like your assignment done free from plagiarism by an expert? Place your order now and it shall be done within the timeframe you indicate.

To view and download a complete answer, scroll down to the bottom to pay Pay to view