fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Idinahui{
  6.  
  7. public static void main (String[] args) throws java.lang.Exception{
  8. Idinahui idi = new Idinahui();
  9. //Console console = System.console();
  10. //String s = console.readLine("Enter text:");
  11. String s = "Idi nahui";
  12. idi.idinah(s);
  13. }
  14.  
  15. public void idinah(String s) throws java.lang.Exception {
  16. char[] charArray = s.toCharArray();
  17. int[] codes = new int[charArray.length-1];
  18. for (int i=0; i<=charArray.length; i++){
  19. codes[i] = (int) charArray[i];
  20. }
  21. byte[] b = new byte[codes.length];
  22. for (int i=0; i<=codes.length; i++){
  23. b[i] = (byte) codes[i];
  24. }
  25. String idina = new String(b, "UTF-8");
  26. System.out.print(idina);
  27. }
  28.  
  29. }
Runtime error #stdin #stdout #stderr 0.09s 320576KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 8
	at Idinahui.idinah(Main.java:19)
	at Idinahui.main(Main.java:12)