Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Added: May 5, 2021 3:49 PM
Views: 502
Tags: collections
  1.  public static void main(String[] args) {
  2.  
  3.         //Initialisieren wie ArrayLists
  4.         var colors = new HashSet<String>();
  5.  
  6.         // use add() method to add values in the hash set
  7.         colors.add("Red");
  8.         colors.add("Green");
  9.         colors.add("Black");
  10.         colors.add("White");
  11.         colors.add("Pink");
  12.         colors.add("Yellow");
  13.  
  14.  
  15.         var num = colors.size();
  16.  
  17.         System.out.println("Number of Elements: " + num);
  18.     }
  19. }
  20.