So, here the question !
Write a Java code of the method startsWithCount that takes an array of strings words and a String S. The method should return an integer that is the number of strings that starts with S.
For example if:
words = { "All", "Arab", "size", "Almond", "Allowed", "here"} and S= "All", then the method should return 2
This is what I have tried - This is the following answer right. Need help?
PHP Code:
public class StringwithCount {
public static void main (String[]args) {
String strings[] = { "All", "Arab", "size", "Almond", "Allowed", "here"};
String output= "";
for ( int i = 0; i < words.length; i++) {
if (words[i].startsWith("s"))
c + +;
}