How to write a java program to reverse a string without using string functions?
String a="Siva";
for(int i=0;i<=a.length()-1;i++)
{
System.out.print(a.charAt(i));
}
System.out.println("");
for(int i = a.length() - 1; i >= 0; --i)
{
System.out.print(a.charAt(i));
}
here charAt() and a.length() are string functions
This will help
public class StringReverse {
public static void main(String[] args){
String str = "Reverse";
StringBuilder sb = new StringBuilder(str);
str = sb.reverse().toString();
System.out.println("ReverseString : "+str);
}
}
There is no usage of String methods
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With