fork download
  1. import java.io.*;
  2. class Example
  3. {
  4. public static void main(String args[])
  5. {
  6. int count=0;
  7. String word1="SLUM REHABILITATION";
  8. String word2="SOCIAL ENTREPRENEURSHIP ", result=" ";
  9. for(int i=0;i<word1.length();i++)
  10. {
  11. count=0;
  12. for(int j=0;j<word2.length();j++)
  13. {
  14. if(word1.charAt(i)==word2.charAt(j))
  15. {
  16. for(int k=0;k<result.length();k++)
  17. {
  18. if((result.charAt(k)==word1.charAt(i))||(word1.charAt(i)==' '))
  19. {count=1;}
  20.  
  21. }
  22. if(count==0)
  23. result=result+","+word1.charAt(i);
  24. }
  25.  
  26. }
  27. }
  28. System.out.println(result);
  29. }
  30. }
  31.  
  32.  
Success #stdin #stdout 0.08s 212416KB
stdin
Standard input is empty
stdout
 ,S,L,U,R,E,H,A,I,T,O,N