Set Introduction

 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());
}


}


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.