View Single Post
Old 02-09-07, 12:12 PM   #4
Imbroglio's Avatar
Join Date: Mar 2004
Posts: 1,271
Default Re: Java Help: Reversing Letters in a String

sounds to me like you are storing the string as one long continuous entity. what you need to do is parse the string based on ascii value 32 (space) or value 10 (new line) or value 0 (null - end of string). once you parse each string into the subsequent substrings, you can reverse the substrings and print them back adding the spaces between them.

in you for loop test to make sure the char isn't one of these values,
for (looping){
building word;
if (space/NL/LF/null){
reverse string
print string (to file or screen)
string = '\0' (clear string)
}//continue working through entire string.

HT: 360 -- Sony60A3000 -- Onkyo SR605 --> Polk cs2, monitor 60s and monitor 40s w/ Bic F12 sub -- PS3
XBL:Mr X3r0 -- PSN:Mr_X3r0

Rig- Asus P6X58D Premium - intel i7 920 @3.6 - EVGA GTX570 - Corsair HX1000 - Prolimatech Mega Shadow - WD640 - COOLER MASTER ATCS 840 - OCZ Gold 6GB DDR3 1600*

Imbroglio is offline   Reply With Quote