[java]afficher mot par mot

Bonjour,
j'écris ce prg qui sert afficher le phrase en mot par mot
mais après le résultat,s'affiche caractère par caractère
aidez moi s'il vous plaît
package Textprg;
import java.util.Scanner;
public class Wordsinstring 
{
	public static void main(String[] args)
	{
		String line;
		int i;
		char ch;
		boolean estcechar=true;
		System.out.println("Entrez votre phrase");
		Scanner sc=new Scanner(System.in);
		line=sc.nextLine();
				
		for(i=0;i<line.length();i++)
		{
			ch=line.charAt(i);
			if(Character.isLetter(ch))
			   {
				System.out.println(ch);
				estcechar=false;
			   }
			else
			{
				if(estcechar==false)
				{
					
					estcechar=true;
				}
			}
		
		}
		
	}

}


resultat est
Entrez votre phrase
je suis dans l'école
j
e
s
u
i
s
d
a
n
s
l
é
c
o
l
e

1 réponse

  • Votes
  • Date
  • Date décroissante