Answer :
Answer:
This question is answered using Java programming language:
public static void print10(String[]arr){
for(int i =0; i<10;i++){
System.out.println(arr[i]);
}
}
Explanation:
This line defines the method
public static void print10(String[]arr){
This iterates from 0 to 9 index of the array. In other words, 1st to 10th
for(int i =0; i<10;i++){
This prints the required output (one on a line)
System.out.println(arr[i]);
}
}
Refer to attachment for the complete program that includes the main method.
Following are the program to count array words:
Program Explanation:
- Defining a class "Main".
- Inside the class, a method "print10" is declared that takes an array of string inside the parameter, and define a for loop that prints 10 string value.
- Outside the method, the main method is declared that defines the array of strings that holds string value and passes the value into the method "print10" and prints its value.
Program:
public class Main //defining a class Main
{
private static void print10(String[] di)//defining a method print10
{
System.out.println("First 10 words in string array: ");//print message
for(int i=1; i<11; i++)//defining a loop that prints array value
{
System.out.println(i+"\t "+di[i]);//print array value
}
}
public static void main(String[] a) //defining main method
{
String[] di = {"Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Julie", "Kilo", };//defining array of String that hold value
print10(di);//calling method and print its value
}
}
Output:
Please find the attached file.
Learn more:
brainly.com/question/7052857

