0
What's the error
Please correct it https://code.sololearn.com/cD6TxxCpN1c1/?ref=app
2 Respostas
+ 14
● there are too many unnecessary spaces , after removing them , there will be no compilation error.
● but still the output of code will be "No output" as for every ch=str.chatAt(i) , where i from 0 to (length of String-1) will be present in String so if condition will be always false.
//here is code after removing white space :
public class Program
{
public static void main(String args[]) {
String str="bumblebeem";
char ch=' ';
String ts = "";
for (int i=0;i<str.length();i++) {ch=str.charAt(i);
if(str.indexOf(ch)==-1)
ts+=ch;
}
System.out.println(ts);
}
}
0
How could i get my answer