fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4.  
  5.  
  6. public class Main {
  7.  
  8.  
  9. public static void main(String[] args)throws IOException {
  10.  
  11. Scanner in=new Scanner(System.in);
  12. int n,l,flag=0,i,ln;
  13. String q="",c="",ch="";
  14. n=in.nextInt();
  15. ArrayList g1=new ArrayList();
  16. do{
  17. ch=inp.readLine();
  18. if(ch.equalsIgnoreCase("q00"))
  19. {
  20. q=ch;
  21. ln=g1.size();
  22. System.out.println(ln);
  23. if(ln%2==0&&ln!=0)
  24. {
  25. flag++;
  26. }
  27. System.out.println(flag);
  28. }
  29. else if(ch.equalsIgnoreCase("-1"))
  30. System.exit(0);
  31. else
  32. {
  33. c=ch;
  34. l=c.length();
  35. char a=ch.charAt(1);
  36. char b=ch.charAt(2);
  37. Iterator itr=g1.iterator();
  38. while(itr.hasNext())
  39. {
  40. char chk=(char) itr.next();
  41. if(chk!=a||chk!=b)
  42. {
  43. g1.add(a);
  44. g1.add(b);
  45. }
  46.  
  47.  
  48. }
  49. }
  50. System.out.println(g1);
  51. }while(n!=0);
  52. }
  53.  
  54. }
  55.  
Runtime error #stdin #stdout #stderr 0.13s 321344KB
stdin
5
c12
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.NullPointerException
	at Main.main(Main.java:19)