Class Rverse{

static String reverso(String palabra){
StringBuilder aa=new StringBuilder(palabra);
return aa.reverse().toString();
}

public static void man(String[] args){

String Almabo ="indetectables.net";

System.out.println(reverso(Almabo));

}
}
Si me permitís te la corrijo un poco:

Código: Seleccionar todo

class Reverse {

	public static void main(String[] args){
		String Almabo ="indetectables.net";
			System.out.println(reverso(Almabo));
	}
	
	private static String reverso(String almabo){
		StringBuilder aa = new StringBuilder(almabo);
			return aa.reverse().toString();
	}
	
}
Muy bien un saludo!
Imagen
iba a proponer utilizar la clase StringBuffer para utilizar el metodo reverse().. pero mirando el Java Docs me he dado cuenta de lo siguiente:
This class provides an API compatible with StringBuffer, but with no guarantee of synchronization. This class is designed for use as a drop-in replacement for StringBuffer in places where the string buffer was being used by a single thread (as is generally the case). Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations.
Así que nada.. todo perfecto entonces =)

Un saludo! R-007
Responder

Volver a “Otros lenguajes”