How to reverse a string without using inbuilt function in java

What you will learn here about Java

  • How to reverse a string without using inbuilt function in java

How to reverse a string without using inbuilt function in java

Sample program to know how to reverse a string without using inbuilt function in java or how to reverse a string without using API in java

public class ReverseString {

	public static void main(String[] args) {
		
			reverse("Joker");
	}

	
	public static String reverse(String str) {
		String reverse="";
		for(int i=str.length()-1;i>=0;i--) {
			reverse+=str.charAt(i);
		}
		
		System.out.println(reverse);
		return reverse;
	}
}

OUTPUT

rekoJ

You may also like...