Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.HashSet;

public class Main {
    public static void main(String args[]) {
        HashSet<String> newset = new HashSet<String>();

        // populate hash set
        newset.add("Learning");
        newset.add("from");
        newset.add("java2s.com");

        // checking elements in hash set
        System.out.println("Hash set values: " + newset);

        // clear set values
        newset.clear();

        System.out.println("Hash set values after clear: " + newset);
    }
}