I am new to Java, With respect to this question remove same values from an array How can we achieve it using java. Any help would be greatly appreciated?
Asked
Active
Viewed 219 times
3 Answers
2
You could use a Set (e.g. HashSet), or a Map (e.g. HashMap). For each value in the array, just place it in the Set (or as a key in the Map).
You will then have a collection without duplicates (you can transform it back to an array if you need).

Alexey
- 318
- 1
- 2
- 10
0
You can achieve this simply by using the collections.
use set or HashMap and put the elements in the collections. when you retrieve you will get the unique elements .
If you are looking for pattern matching... better for the RegEx.

Shailej Shimpi
- 145
- 2
- 3