Java ICSE Class 10 :
Enter a string in java and print the largest word in it and count it's letters.
Answers
Answered by
0
Answer:
// Java program to find the number of charters
// in the longest word in the sentence.
class GFG {
static int LongestWordLength(String str)
{
String[] words = str.split(" ");
int length = 0;
for(String word:words){
if(length < word.length()){
length = word.length();
}
}
return length;
}
// Driver code
public static void main(String args[])
{
String str = "I am an intern at binscomputer.com";
System.out.println(LongestWordLength(str));
}
}
Output:
15
Explanation:
Similar questions
Math,
5 months ago
Accountancy,
5 months ago
India Languages,
5 months ago
Math,
11 months ago
Hindi,
1 year ago
Math,
1 year ago
English,
1 year ago