Answers for "easily reverse a string java"

3

reverse string java

String string="whatever";
String reverse = new StringBuffer(string).reverse().toString();
System.out.println(reverse);
Posted by: Guest on October-14-2020
0

String reverse in java

1)
String str = "Hello";
String result = "";

  for(int i = str.length()-1; i>=0; i--){
     result += str.charAt(i); // first solution, charAt method
 //  result += str1.substring(i, i+1); // first solution,  substring method
   }
   System.out.println(result);
}
Posted by: Guest on June-04-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language