import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.TreeSet; public class ArraySplitAndSort { public static void main(String args[]) throws Exception{ String kodeTest = "C,X,C,C,T"; String[] kodeArray = kodeTest.split(","); List<String> hasilList = Arrays.asList(kodeArray); Set<String> hasilAkhir = new TreeSet<String>(hasilList); System.out.println(hasilList.toString()); System.out.println(hasilAkhir.toString()); } }
Hasil Eksekusi :
[C, X, C, C, T]
[C, T, X]
No comments:
Post a Comment