Created
September 17, 2019 15:22
-
-
Save youngjinmo/0a190818288088dac5ae69e0315f1cf1 to your computer and use it in GitHub Desktop.
문자열 알파벳 역순으로 정렬하기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class orderByAsciiReverse { | |
public static String orderByinReverse(String str){ | |
String[] temp = str.split(""); | |
Arrays.sort(temp, Collections.reverseOrder()); | |
String changed = ""; | |
for (int i = 0; i < temp.length; i++) { | |
changed += temp[i]; | |
} | |
return changed; | |
} | |
public static void main(String[] args) { | |
String data = "Hello World"; | |
System.out.println(orderByinReverse(data)); | |
// roollledWH | |
System.out.println(orderByinReverse(data).length()); | |
// 11 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment