If you need unique things then we have Set in java
String[] users = "User1,User2,User1,User,User".split(",");
Set uniquUsers = new HashSet();
for (int i = 0; i < users.length; i++) {
if (!uniquUsers.add(users[i]))
users[i] = "Duplicate"; // here I am assigning Duplicate instead if find duplicate
// you can assign as null or whatever you want to do with duplicates.
}
System.out.println(Arrays.toString(users));