string reverse in java using char array code example
Example 1: java string reverse
String rev = new StringBuilder("Your String").reverse().toString();
Example 2: Reverse a string in java
class ReverseStringByteArray
{
public static void main(String[] args)
{
String input = "HelloWorld";
byte[] strByteArray = input.getBytes();
byte[] output = new byte[strByteArray.length];
for(int a = 0; a < strByteArray.length; a++)
output[a] = strByteArray[strByteArray.length - a - 1];
System.out.println(new String(output));
}
}