fork(1) download
  1. import java.util.*;
  2.  
  3. class Main{
  4. public static void main (String args[]){
  5. String str = "Hello world";
  6. String str1 = "word";
  7.  
  8. char []ch = str.toCharArray();
  9. char []ch1 = str1.toCharArray();
  10. List<Character> al = new ArrayList();
  11.  
  12. StringBuilder sb = new StringBuilder();
  13.  
  14. for (int i=0;i<ch1.length;i++){
  15. for(int j=0;j<ch.length;j++){
  16. if (ch1[i] == ch[j]){
  17. al.add(ch1[i]);
  18. System.out.println("al -- " + al.get(i));
  19. }
  20. }
  21. }
  22. System.out.println("al" + al.size());
  23. for (int i=0;i<al.size();i++){
  24. if(!(str.contains(String.valueOf(al.get(i))))){
  25. sb = sb.append(String.valueOf(al.get(i)));
  26. }
  27. }
  28. System.out.println(":::" + sb.toString());
  29. }
  30. }
Success #stdin #stdout 0.15s 55628KB
stdin
Standard input is empty
stdout
al -- w
al -- o
al -- o
al -- o
al -- r
al5
:::