0
I am getting a fault in solving the code coach.
I have done the flowing word code coach by myself when I was doing it in code playground and it ran well even I checked it on a compiler and that time it also ran well but when I copied it and pasted it in the code coach that time it is getting mistakes. I tried to check the conditions of the code coach in the code playground but no faults. Idk why it is happening 😢☹️ https://code.sololearn.com/cks7Fhgfy00h/?ref=app
5 Réponses
+ 2
五条悟 
it is unnecessary to go to the next loop when you have already known b is false
you should break the loop then
```
if((s.charAt(i-1))==(s.charAt(i+1)))
	b=true;
else {
	b=false;
	break;
}
```
+ 1
try to comment out this line:
`System.out.println(s);`
+ 1
import java.util.*;
public class Program
{
    public static void main(String[] args) 
    {
        Scanner in=new Scanner(System.in);
        //System.out.print("Enter a String: ");
        String s=in.nextLine();
        //System.out.println(s);
        s=s.trim();
        String wd="";
        boolean b=false;
        for(int i=0;i<s.length();i++)
        {
            char ch=s.charAt(i);
            if(ch==' ')
            {
                if((s.charAt(i-1))==(s.charAt(i+1)))
                    b=true;
                else{
                    b=false;
                    break;
                }
            }
            else
                wd=wd+ch;
        }
        //if(b==true)
            //System.out.println("Flowing Words");
        //else
            System.out.println(b);
    }
}
0
o.gak I have replaced the flowing words output to true and false and removed all the unnecessary parts but still it is showing that there is a mistake
I have removed the line numbers:- 1, 6, 7, 9 and changed line 8 to String s=""; but still 😩






