더 좋은 풀이 있으면 공유합시다..


  1. package myTest;
  2.  
  3. import java.util.Arrays;
  4.  
  5. public class Test {
  6. public static void main(String[] args) {
  7. Test test = new Test();
  8. System.out.println(test.reverseInt(13245768));
  9. }
  10.  
  11. public int reverseInt(int n) {
  12. char[] chars = (n+"").toCharArray();
  13. Arrays.sort(chars);
  14. StringBuilder sb = new StringBuilder(new String(chars)).reverse();;
  15. return Integer.parseInt(sb.toString());
  16. }
  17. }