Page 1 of 1
[HELP] JAva reverse()
Posted: Thu Dec 02, 2010 1:40 am
by aquilina
someone can help me in java? i using reverse method... how to reverse specific words in a sentences....??
Re: [HELP] JAva reverse()
Posted: Fri Dec 03, 2010 2:06 am
by KFSPC8
by REVERSING words did u mean like changing
XEMECTRUM to MURTCEMEX
LOL
Re: [HELP] JAva reverse()
Posted: Fri Dec 03, 2010 4:45 pm
by aquilina
nope... example this sentences.." i love emectrum"
the output gonna be like this " i evol emectrum"
i only wanna reverse the "love" word...
Re: [HELP] JAva reverse()
Posted: Tue Dec 28, 2010 9:14 pm
by wizme
Hi, you need a function to reverse certain words in a sentence or whole sentence?
Normally for reversing we will use array, i'm not sure about java.
If you need to choose certain word to reverse in a sentence, try doing this:
Split the sentence by space into an array.
Ask user which word(which element in the array) he want to reverse.
Reverse it using "array[element index] = new StringBuffer(array[element index]).reverse().toString();"
Join back the array to get sentence.
Re: [HELP] JAva reverse()
Posted: Tue Jan 04, 2011 2:48 pm
by aquilina
wizme wrote:Hi, you need a function to reverse certain words in a sentence or whole sentence?
Normally for reversing we will use array, i'm not sure about java.
If you need to choose certain word to reverse in a sentence, try doing this:
Split the sentence by space into an array.
Ask user which word(which element in the array) he want to reverse.
Reverse it using "array[element index] = new StringBuffer(array[element index]).reverse().toString();"
Join back the array to get sentence.
Btw thankx =D i have found others function
