Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code

Sunday

JAVA PROGRAMMING TUTORIAL 40 : HashSet

//HashSet is used to remove the duplicate term in the list

import java.util.*;

public class HackDefence{

public static void main(String[] args){

              String[]country = {"India","Pakistan","America","India","China"};

              List<String> countryList = Arrays.asList(country);

              System.out.printf("Before the use of HashSet :" + "%s",countryList);

              System.out.println();

              Set<String>set = new HashSet<String>(countryList);
 
              System.out.printf("After the use of HashSet :" + "%s",set);
 
      }

}

OUTPUT:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...