Skip to content

Instantly share code, notes, and snippets.

@youngjinmo
Created September 17, 2019 15:22
Show Gist options
  • Save youngjinmo/0a190818288088dac5ae69e0315f1cf1 to your computer and use it in GitHub Desktop.
Save youngjinmo/0a190818288088dac5ae69e0315f1cf1 to your computer and use it in GitHub Desktop.
문자열 알파벳 역순으로 정렬하기
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