java.util.HashSet.remove() 方法


java.util.HashSet.remove() 方法

package com.codingdict;

import java.util.*;

public class HashSetDemo {
   public static void main(String args[]) {

      // create hash set
      HashSet <String> newset = new HashSet <String>();

      // populate hash set
      newset.add("Learning");
      newset.add("Easy");
      newset.add("Simply");  

      System.out.println("Values before remove: "+newset);

      // remove "Easy" from set
      boolean isremoved = newset.remove("Easy");

      System.out.println("Return value after remove: "+isremoved);

      System.out.println("Values after remove: "+newset);     
   }    
}