Reversing the words order of a string
 
Clash Royale CLAN TAG #URR8PPP   .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;     up vote  1  down vote  favorite     A couple of weeks I had a coding interview and the problem to solve was very simple: reverse the words order of a string. What did I do wrong here? public static String reverse(String phrase)  String words = phrase.split(" ");  StringBuffer sb = new StringBuffer();  for (String word : words)  String reversed = new String();  for (int j = word.length() - 1; j >= 0; j--)  reversed += word.charAt(j);   sb = sb.append(reversed).append(" ");   return sb.toString().substring(0, sb.toString().length() - 1);     java strings interview-questions    share | improve this question      edited Jan 3 at 23:19       Jamal ⦠  30.1k 11 114 225        asked Jan 3 at 22:27       Eliú Abisaà DÃaz Vásquez   8 2       	         String reversed = new String();  this doesn't look go...