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 without using reverse function
// Reverse a string in java without using reverse function
import java.util.Scanner;
public class ReverseWithoutFunction
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Please enter a string: ");
String strInput = sc.nextLine();
int len = strInput.length();
String strReverse = "";
System.out.println("Reverse a string without using reverse function: ");
for(int a = len - 1; a >= 0; a--)
{
strReverse = strReverse + strInput.charAt(a);
}
System.out.println(strReverse);
sc.close();
}
}
reverse string array java
import java.util.Arrays;
public class ReverseStringArrayInJava
{
public static void main(String[] args)
{
String[] strHierarchy = new String[]{"Junior Developer","Senior Developer","Team Lead","Project Manager","Senior Manager","CEO"};
System.out.println("Given string array: " + Arrays.toString(strHierarchy));
for(int a = 0; a < strHierarchy.length / 2; a++)
{
String strTemp = strHierarchy[a];
strHierarchy[a] = strHierarchy[strHierarchy.length - a - 1];
strHierarchy[strHierarchy.length - a - 1] = strTemp;
}
System.out.println("Reversed string array: ");
for(int a = 0; a < strHierarchy.length; a++)
{
System.out.println(strHierarchy[a]);
}
}
}
String reverse in Java
StringBuilder sb1 = new StringBuilder("Mahmut");
sb1.reverse();
System.out.println(sb1); // tumhaM
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