fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. ArrayList<String> arr = new ArrayList();
  11. String str,str2;
  12. String empty = "";
  13. Scanner input = new Scanner(System.in);
  14. str = input.nextLine();
  15. for(int i = 0;i < str.length(); i++)
  16. {
  17. str2 = empty;
  18. str2 += str.charAt(i);
  19. //arr.Add(str.charAt(i));
  20. if(i == str.length()-1)
  21. arr.add(str2);
  22. else
  23. {
  24. if(str.charAt(i) == str.charAt(i+1))
  25. i++;
  26. else arr.add(str2);
  27. }
  28. }
  29. for(int i = 0;i < arr.size();i++)
  30. {
  31. System.out.print(arr.get(i));
  32. }
  33. }
  34. }
Success #stdin #stdout 0.09s 2841600KB
stdin
aaxxccff
stdout
Standard output is empty