[HELP] JAva reverse()

Discuss about Programming here. You may release your source, post guide and even ask questions!

Moderator: wizme

Post Reply
aquilina
Sacrificer
Sacrificer
Posts: 32
Joined: Tue Jan 26, 2010 2:20 pm

[HELP] JAva reverse()

Post by aquilina »

someone can help me in java? i using reverse method... how to reverse specific words in a sentences....??
User avatar
KFSPC8
Master of Darkness
Master of Darkness
Posts: 494
Joined: Sat Jun 05, 2010 6:18 pm
Location: Singapore

Re: [HELP] JAva reverse()

Post by KFSPC8 »

by REVERSING words did u mean like changing
XEMECTRUM to MURTCEMEX
LOL
aquilina
Sacrificer
Sacrificer
Posts: 32
Joined: Tue Jan 26, 2010 2:20 pm

Re: [HELP] JAva reverse()

Post 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...
wizme
Destiny General
Destiny General
Posts: 297
Joined: Sat Sep 05, 2009 1:40 pm

Re: [HELP] JAva reverse()

Post 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.
Unlike science, love is like magic, there's no reason to it - wizme =)
Learn more of security, click here =)
aquilina
Sacrificer
Sacrificer
Posts: 32
Joined: Tue Jan 26, 2010 2:20 pm

Re: [HELP] JAva reverse()

Post 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 :D
Post Reply