fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13.  
  14. String s = " ";
  15. //Scanner scan = new Scanner(System.in);
  16. //String s = scan.nextLine();
  17. // Write your code here.
  18. if (s.matches("[A-Za-z !,?._'@]+")){
  19.  
  20. System.out.println("["+s.trim().isEmpty()+"]");
  21. String ss = s.trim();
  22. char aaa = ss.charAt(0);
  23. System.out.println("{"+aaa+"}");
  24.  
  25. String [] arr = s.trim().split("[ !,?._'@]+");
  26. System.out.println(arr.length);
  27.  
  28.  
  29. //s.charAt(8)
  30. for (String retval: arr) {
  31. System.out.println("["+retval+"]");
  32. }
  33. }
  34. // scan.close();
  35. }
  36. }
Runtime error #stdin #stdout #stderr 0.06s 2841600KB
stdin
Standard input is empty
stdout
[true]
stderr
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.lang.String.charAt(String.java:658)
	at Ideone.main(Main.java:22)