Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Thierry van der Zon
291 PointsExercise for school. Hi i am a starting programmer from the netherlands but I need to do exercise for school. I really
Hi i am a starting programmer from the netherlands but I need to do exercise for school. I really don't understand how i should do it. I need to make a program in java to turn words around. So when i put in a sentence, there comes the same sentence out but the words are turned around. So for example, I am the best programmer ever.... there comes out""I ma eht tseb remmargorp reve. thanks in advance
2 Answers
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points- split the sentence into an array
- then reverse each word in the array
- then turn the array back into a string
Lester Peterkin
10,359 PointsString sentence = "hello mate how are you"; String[] words = sentence.split(" ");
The code above splits the String sentence into 5 word Strings which are stored in the words array