I have an array of string, which holds the list of strings. I want to figure out is there any duplicate entries in this list. Basically i have a list of users, and there should be no duplicate entries.
you can add the String array to the HashSet
Set<String> h = new HashSet<String>(Arrays.asList(new String[] { "a", "b" }));
this will get you unique String values. If necessary convert the HashSet back to array
String[] uniqueValues = h.toArray(new String[0]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With