Reverse words in string. Some questions about distributed system.
Anonymous
//Reverse words in string public static String reverseWords(String str) { String[] strs = str.split("\\s+"); StringBuffer buffer = new StringBuffer(); boolean isFirst = true; for(int i = strs.length-1; i >= 0; i--) { if(isFirst) { isFirst = false; } else { buffer.append(" "); } buffer.append(strs[i]); } return buffer.toString(); }
Check out your Company Bowl for anonymous work chats.