Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
LinkedList removeLast() Method in Java
Next article icon

LinkedHashSet remove() method in Java

Last Updated : 30 Sep, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

The Java.util.LinkedHashSet.remove(Object O) method is used to remove a particular element from a LinkedHashSet.

Syntax:

LinkedHashSet.remove(Object O)

Parameters: The parameter O is of the type of LinkedHashSet and specifies the element to be removed from the LinkedHashSet.

Return Value: This method returns True if the specified element is present in the LinkedHashSet otherwise it returns False.

Below program illustrate the Java.util.LinkedHashSet.remove(Object O) method:




// Java code to illustrate LinkedHashSet.remove() method
import java.util.*;
import java.util.LinkedHashSet;
  
public class LinkedHashSetDemo {
    public static void main(String args[])
    {
        // Creating an empty LinkedHashSet
        LinkedHashSet<String> set = new LinkedHashSet<String>();
  
        // Use add() method to add elements into the Set
        set.add("Welcome");
        set.add("To");
        set.add("Geeks");
        set.add("4");
        set.add("Geeks");
  
        // Displaying the LinkedHashSet
        System.out.println("LinkedHashSet: " + set);
  
        // Removing elements using remove() method
        set.remove("Geeks");
        set.remove("4");
        set.remove("Welcome");
  
        // Displaying the LinkedHashSet after removal
        System.out.println("LinkedHashSet after removing "
                           + "elements: " + set);
    }
}
 
 
Output:
  LinkedHashSet: [Welcome, To, Geeks, 4]  LinkedHashSet after removing elements: [To]  


Next Article
LinkedList removeLast() Method in Java
author
gopaldave
Improve
Article Tags :
  • Java
  • Java-Functions
  • java-LinkedHashSet
Practice Tags :
  • Java

Similar Reads

  • LinkedList remove() Method in Java
    In Java, the remove() method of the LinkedList class removes an element from the list, either by specifying its index or by providing its value. Example 1: Here, we use the remove() method to remove element from the LinkedList of Strings. By default the remove() will remove the beginning element(hea
    3 min read
  • LinkedHashSet size() method in Java
    The Java.util.LinkedHashSet.size() method is used to get the size of the LinkedHashSet or the number of elements present in the LinkedHashSet. Syntax: Linked_Hash_Set.size() Parameters: This method does not takes any parameter. Return Value: The method returns the size or the number of elements pres
    1 min read
  • LinkedList removeLast() Method in Java
    In Java, the removeLast() method of LinkedList class is used to remove and return the last element of the list. Example 1: Here, we use the removeLast() method to remove and return the last element (tail) of the LinkedList. [GFGTABS] Java // java Program to demonstrate the // use of removeLast() in
    2 min read
  • LinkedList removeFirst() Method in Java
    In Java, the removeFirst() method of the LinkedList class is used to remove and return the first element of the list. Example 1: Here, we use the removeFirst() method to remove the first element (head) of the LinkedList of Integers. [GFGTABS] Java // Java Program to demonstrate the // use of removeF
    2 min read
  • LinkedTransferQueue remove() method in Java
    The java.util.concurrent.LinkedTransferQueue.remove() method is an in-built function in Java which is used to remove an element if it is present in this queue. Syntax: LinkedTransferQueue.remove(Object o) Parameters: The function accepts a single parameter o i.e. the object to be removed. Return Val
    2 min read
  • LinkedHashSet removeAll() method in Java with Example
    The removeAll() method of java.util.LinkedHashSet class is used to remove from this set all of its elements that are contained in the specified collection. Syntax: public boolean removeAll(Collection c) Parameters: This method takes collection c as a parameter containing elements to be removed from
    3 min read
  • LinkedHashMap removeEldestEntry() Method in Java
    The java.util.LinkedHashMap.removeEldestEntry() method in Java is used keep a track of whether the map removes any eldest entry from the map. So each time a new element is added to the LinkedHashMap, the eldest entry is removed from the map. This method is generally invoked after the addition of the
    3 min read
  • LinkedHashSet isEmpty() method in Java
    The Java.util.LinkedHashSet.isEmpty() method is used to check if a LinkedHashSet is empty or not. It returns True if the LinkedHashSet is empty otherwise it returns False. Syntax: Linked_Hash_Set.isEmpty() Parameters: This method does not take any parameter Return Value: The function returns True if
    1 min read
  • LinkedList set() Method in Java
    The Java.util.LinkedList.set() method is used to replace any particular element in the linked list created using the LinkedList class with another element. This can be done by specifying the position of the element to be replaced and the new element in the parameter of the set() method. Syntax: Link
    3 min read
  • LinkedList pop() Method in Java
    In Java, the pop() method of the LinkedList class is used to remove and return the top element from the stack represented by the LinkedList. The method simply pops out an element present at the top of the stack. This method is similar to the removeFirst method in LinkedList. Example 1: Here, we use
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences