2nd Jan 2019, 4:52 PM
Vivek Mishra
Vivek Mishra - avatar
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); } }
2nd Jan 2019, 6:47 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
0
How could i get my answer
3rd Jan 2019, 2:33 PM
Vivek Mishra
Vivek Mishra - avatar