Java program to find the longest word in a string (Need simple answer please!!)
Answers
Answered by
2
first find the length then
int c=0;
String longest;
for (i=0;i<l;i++)
{
char ch =st. charAt(i);
if (ch!=' ')
w=w+ch;
else
{
l1 =w.length();
if (l1>c)
longest=w;
}
}S.o .pln(longest);
Similar questions