android - how to remove duplicate Element from Arraylist in java -


    { "744101", "744101","744101", "744102",744102","744102","744102","744102","744103","744103"}       list<string> list2=new new arraylist<string>();  //            arrays.sort(iarr);                             for(int k=0;k<iarr.length;k++) {                                 list2.add(string.valueof(iarr[k]));                             }     list li2 = new array list(new hashset(list2));  

i'm unable result while trying sort array list. please correct me.

the treeset both sorts elements , removes duplicates.

    string[] array = { "744101", "744101","744101", "744102","744102","744102","744102","744102","744103","744103"};     list<string> list = new arraylist<>(new treeset<>(arrays.aslist(array)));      list.foreach((element)->{         system.out.println(element);     }); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -