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




Picture showing the output of Set in Java
Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Monday, January 30, 2017

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250