void addLine(String)
Other methods called: addWord(String)
This is a simple method that performs two very important operations.
First it ensures that the line being read is not 0 length. This is important because without this functionality an empty string (blank line) will break the program.
Once a String is determined to have content, the String is split into individual words. These words are then passed to the addWord(String) method.

Respuesta :

Answer:

Following are the code to this question:

void addLine(String s)//defining a method addLine that accepts String variable as a parameter

{

if(s.trim().length()==0)//using if block that trims string value and check length is equal to 0

{

return;//use return keyword

String a[]=s.split(" ");//defining array as a string that split array and hold value

for(String x:a)//using for loop that hold array value

{

addWord(x);//use addWord to add string value

}

}

}

Explanation:

In this code, a method "addLine" is declared, that accepts string variable "s" as a parameter and in the next line, it uses the if block that trims string value and uses length that checks its value is equal to 0.

In the next step, a string array "a" uses the split method to hold string value, and in the for loop, it uses the addWord method to add string value.