Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Order {
- public static String order(String words) {
- if (words.isEmpty()) {
- return words;
- }
- String[] splittedWords = words.split(" ");
- String[] outputTab = new String[splittedWords.length];
- for (int i = 0; i < splittedWords.length; i++) {
- String word = splittedWords[i];
- for (int j = 0; j < word.length(); j++) {
- char c = word.charAt(j);
- if (c > 47 && c < 58) {
- int index = Character.getNumericValue(c);
- outputTab[index - 1] = word;
- }
- }
- }
- String combinedString = "";
- for (String s : outputTab) {
- combinedString += s + " ";
- }
- return combinedString;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement