Duplicate Elimination in java -
i need write program enter 5 numbers 10 100 don't know how can eliminate duplicates? got bright ideas on how can it?
use set implementation whic definition not contain duplicates...
treeset<integer> ints = new treeset<integer>(); int[] int_array = { 1, 2, 3, 4, 3, 5, 4, 2, 3, 4, 3 4, 2, 1 }; (int n : int_arr) ints.add(n); (int n : ints) system.out.preintln(n);
outputs: 1 2 3 4 5
Comments
Post a Comment