mad turnip wrote: » We had this question before in an interview and the girl literly submitted: new Stringbuilder(str).reverse() I couldn't stop laughing, there was another similar question of sorting a list and in that one she did: Collections.sort(list); I still can't stop laughing at it. And it was so cheeky she got the job!!!!!!!!!!!!
ChRoMe wrote: » Why wouldn't she say that, its a completely valid and correct answer. The **** up is on the interviewer not defining the question correctly.
CreepingDeath wrote: » You can use a for-loop to run through the characters from the end backwards to the beginning and add them to a new string. That will reverse the string from eg "ABCDE" to "EDCBA"
carlmango11 wrote: » Maybe building a String from a char array of the reversed String would be better
CreepingDeath wrote: » They only stopped them from using StringBuilder because it has a reverse() method in there already.