MAIN.JAVA:
import java.util.*; public class Main { public static void main(String[] args){ String username, askForContinue; Scanner scan= new Scanner(System.in); Set<String>userset=new HashSet<>(); do { System.out.println("Enter the username"); username= scan.nextLine(); userset.add(username); System.out.println("Do you want to continue?(Y/N)"); askForContinue=scan.nextLine(); } while(askForContinue.equals("Y")); System.out.println("The unique number of usernames is "+userset.size()); } }