reverse string java
String string="whatever";
String reverse = new StringBuffer(string).reverse().toString();
System.out.println(reverse);
reverse string java
String string="whatever";
String reverse = new StringBuffer(string).reverse().toString();
System.out.println(reverse);
how to reverse a string in java
public class ReverseString {
public static void main(String[] args) {
String s1 = "neelendra";
for(int i=s1.length()-1;i>=0;i--)
{
System.out.print(s1.charAt(i));
}
}
}
Reverse a string in java
// reverse a string using reverse() method of StringBuilder class
class ReverseUsingReverseMethod
{
public static void main(String[] args)
{
String str = "Hello world Java";
StringBuilder sb = new StringBuilder();
// append string to StringBuilder
sb.append(str);
sb = sb.reverse();
// printing reversed String
System.out.println(sb);
}
}
Reverse a string in java
// reverse a string using ByteArray
class ReverseStringByteArray
{
public static void main(String[] args)
{
String input = "HelloWorld";
// getBytes() method to convert string into bytes[].
byte[] strByteArray = input.getBytes();
byte[] output = new byte[strByteArray.length];
// store output in reverse order
for(int a = 0; a < strByteArray.length; a++)
output[a] = strByteArray[strByteArray.length - a - 1];
System.out.println(new String(output));
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us