fork(2) download
  1. /* http://es.stackoverflow.com/q/48956/127 */
  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. private static String invertirPalabra(String palabra) {
  11. String res = "";
  12.  
  13. if(palabra.length() == 0){
  14. res = palabra;
  15. }else{
  16. res = invertirPalabra(palabra.substring(1)) + palabra.charAt(0);
  17. }
  18. return res;
  19. }
  20.  
  21. public static void main (String[] args) throws java.lang.Exception
  22. {
  23. String palabraInvertida = invertirPalabra("¡Esta es una prueba!");
  24. System.out.println("Resultado: " + palabraInvertida);
  25. }
  26. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
Resultado: !abeurp anu se atsE¡