Respuesta :

Answer:

import java.util.*;

class StringProgram

{

public static void main(String s[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter a Sentence: ");

String str= sc. nextInt();

// trim the white spaces at the beginning and at the end.

str = str.trim();

int c=0;

int i=0;

while(str.charAt(i++)!=' ')

++c;

System.out.println("Length of the first word in the sentence is: "+c);

}

}

Explanation: