Knowledge Walls
John Peter
Pune, Maharashtra, India
How to use Unique list using SET Class in Core Java with Example
Set interface assures all the Object taken by the add method keep it unique on the Set List. .add() method is used to add the object to the List. Here in this above example String is the Object to persist on the list.

HashSet<String>() Class provides all the definitions of the set interface.
import java.util.HashSet;
import java.util.Set;

public class UniqueSetCollectionExample {
    public static void main(String args[]) throws Exception{    
        Set<String> uniqueUserNames = new HashSet<String>();
[Sarathy, Raja, Gopal]
Best Lessons of "One day One Thing to Know"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details