0
Urgent help
Why is this code returnIng many spaces. I have tried all i can https://code.sololearn.com/cQ5FoHjqP2PO/?ref=app
6 Respuestas
+ 2
The problem is in line 25. When char s in message is space, your if check returns true 26 times. You should put a break there like this:
else if (s == space.charAt(0)){
sb.append(space.charAt(0));
break;
}
+ 1
You should put a break at end of every if() here
alternatively at final correction of spaces you can use
// .split("\\s");
.split("\\s+"); // added +
0
what input is causing problems?
0
zemiak every input. It returns many spacea
0
Aleksandrs Kalinins Thanks, I have seen it
0
zemiak funny enough, I never thought of adding a break. My mistake