I want to know what is going wrong with the below program as it is not returning reversed string.
public class Main {
String reverse(String str){
String rev="";
char ch[]= str.toCharArray();
for(int i=ch.length-1; i>=0; i--){
rev = rev+ch[i];
}
return rev;
}
public static void main(String[] args) {
Main obj = new Main();
obj.reverse("saumya");
}
}