import java.util.Arrays; public class MaxNumber { public static long print(long number) { String num = "" + number; char[] array = num.toCharArray(); Arrays.sort(array); StringBuilder builder = new StringBuilder(); builder.append(array); builder.reverse(); return Long.parseLong(builder.toString()); } }
- import java.util.Arrays;
- public class MaxNumber {
- public static long print(long number) {
return number- String num = "" + number;
- char[] array = num.toCharArray();
- Arrays.sort(array);
- StringBuilder builder = new StringBuilder();
- builder.append(array);
- builder.reverse();
- return Long.parseLong(builder.toString());
- }
- }