- 4
Why not working
take String from user print each word in separate line
4 RĂ©ponses
+ 2
Do not put code in the tag section â instead link it in the description. Describe what the code is supposed to do
0
import java.util.*;
class a
{
public static void main ()
{
Scanner sc=new Scanner (System.in);
System.out.println("enter any String ");
String s=sc.nextLine();
char ch;
int i;
s=s+" ";
String w=" ";
for (i=0 ;i<s.length(); i++)
{
ch=s.charAt(i);
if (ch!=' ')
{
w= w+ch;
}
else {
System.out.println(w);
w=" ";
}
}
}
} // this code is not working please help