Explanation :
If str ="Hello world" then output will be "dlrow olleH".
Code:
public class Reverse{
public static void main(String[] args)
{
String str="Hello world";
String rev="";
for(int i=str.length()-1;i>=0;--i)
{
revs +=str.charAt(i);
}
System.out.println(rev);
}
}
No comments:
Post a Comment