Respuesta :

Answer:

Following are the code to this question:

public class Main//defining a class

{

public static void main(String[] arg)//defining main method

{

  String[] words={"Key","day", "Know", "kind"};//defining array of String words

  int x=0;//defining integer variable for count value

  for(int i=0;i<words.length;i++)//defining for loop for count value

  {

 if(words[i].startsWith("k")||words[i].startsWith("K"))//use if block to check word start from k

  x=x+1;//increment the value of x

  }

System.out.print("The number of letters which starts from k is: "+ x);//print value with message

}

}

Output:

The number of letters which starts from k is: 3

Explanation:

In this code, inside the main method an array of String "words" is defined that hold a value, and in the next step an integer variable "x" is defined, which is used to count the letters, which starts from k.

For this, a for loop is used that counts the value and in this an, if block is defined that uses the "startsWith" method to check the value and increment the value of x and at the last, it prints its value.

ACCESS MORE