Tech Support Guy banner

reverse a string in java

1401 Views 2 Replies 2 Participants Last post by  punjabian263
Hello guys i want to reverse a string in java.e.g
"hello how are u"
it should be displayed as
"u era woh olleh"
i have tried this but unable.

Code:
                                String s="hello how are you";
		String temp=s;
		int j=0;
		for(int i=s.length();i>=0;i--)
		{
			s.chatAt(i)=temp.charAt(j);
			j++;
		}
Status
Not open for further replies.
1 - 2 of 3 Posts
thanks Shadow2531
1 - 2 of 3 Posts
Status
Not open for further replies.
Top