Reverse a String

View previous topic View next topic Go down

Reverse a String

Post  Admin on 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

View user profile http://codefornongeek.forumotion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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