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

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -