This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
What's your approach so far, and where are you having trouble?
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Mar 16, 2006
I am also new to programming.
Since I don't know the length of the array I decided to you and arraylist(). From what I have read you need to dfine an array length and once it is set you cannot chat it without deleteing and redefining it.
Is that the right approach.
I look at the java code and think I could use some of these methods but not exactly sure how to approach the problem..
looking more or less for some psuedo code that will help me with thte thought process.
Java Collection framework is very powerful. It also has some utility classes for lot of algorithmic stuff like sorting, reversing, shuffling etc in java.util.Collections and java.util.Arrays. Here is a sample code:
The OP wanted to reverse the string and not the array. This would reverse the string in the array.
Jon Prais, you need to study the language first and only then will you be able to sollve problems. I should not be posting solutions here but did it because I wanted to show that you can solve the problem without having the length of the array. You can get the length of the array using arrayName.length(i.e. arr.length from above example)
The above code uses the enhanced for-loop. You need Java 5 compiler.