Code For NonGeek
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Reverse a String

Go down

Reverse a String Empty Reverse a String

Post  Admin Sat Aug 27, 2011 2:59 pm

public static void reverse(String str){
if(str==null||str.size==1)
return;
int i=0;
int j=str.size-1;
char temp;
char[] ch=str.toCharArray();
while(i<j){
temp=ch[i];
ch[i]=ch[j];
ch[j]=temp;
i++; j--;
}
return;
}

Admin
Admin

Posts : 131
Join date : 2011-08-16

https://codefornongeek.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum