Articles → Java → Set In Java
Set In Java
What Is Set In Java?
Example
import java.lang.Math; // headers MUST be above the first class
import java.util.*;
// one class needs to have a main() method
public class HelloWorld {
// arguments are passed using the text field below this editor
public static void main(String[] args) {
Set < String > set = new HashSet < String > ();
set.add("Test1");
set.add("Test2");
set.add("Test1");
System.out.println(set);
}
}
Click to Enlarge