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