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.