java - How to delete similar elements from String array or ArrayList -


this question has answer here:

i'm totally new programming , have string array:

string dates[] = {"01-01-1993", "19-11-1993", "01-01-1993", "03-03-2000", "03-03-2000"}; 

in above array dates[0] == dates[2] , dates[3] == dates[4], want delete duplicate values is repeated , want program produce result this:

dates[] = {"01-01-1993", "19-11-1993", "03-03-2000"} 

some using arraylist concept using complex for loops , i'm confused, please in achieving above task.

thanks in advance.

you can use set remove duplicates.

set<t> dateset = new hashset<t>(arrays.aslist(dates)); 

dateset contain unique values.

if need array

dates = dateset.toarray(new string[dateset.size()]); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -