পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Thursday, January 19, 2017

Java.util.HashSet Class

Introduction

The java.util.HashSet class implements the Set interface, backed by a hash table.Following are the important points about HashSet:

  • This class makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time.
  • This class permits the null element.

Class declaration

Following is the declaration for java.util.HashSet class:
public class HashSet<E>
   extends AbstractSet<E>
   implements Set<E>, Cloneable, Serializable

Parameters

Following is the parameter for java.util.HashSet class:
  • E -- This is the type of elements maintained by this set.

Class constructors

S.N. Constructor & Description
1 HashSet()
This constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
2 HashSet(Collection<? extends E> c)
This constructs a new set containing the elements in the specified collection.
3 HashSet(int initialCapacity)
This constructs a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor (0.75).
4 HashSet(int initialCapacity, float loadFactor)
This constructs a new, empty set; the backing HashMap instance has the specified initial capacity and the specified load factor.

Class methods

S.N. Method & Description
1 boolean add(E e)
This method adds the specified element to this set if it is not already present.
2 void clear()
This method removes all of the elements from this set.
3 Object clone()
This method returns a shallow copy of this HashSet instance, the elements themselves are not cloned.
4 boolean contains(Object o)
This method returns true if this set contains the specified element.
5 boolean isEmpty()
This method returns true if this set contains no elements.
6 Iterator<E> iterator()
This method returns an iterator over the elements in this set.
7 boolean remove(Object o)
This method removes the specified element from this set if it is present.
8 int size()
This method returns returns the number of elements in this set(its cardinality).

Methods inherited

This class inherits methods from the following classes:
  • java.util.AbstractSet
  • java.util.AbstractCollection
  • java.util.Object
  • java.util.Set

1 comment:

  1. Nice article on java hashset class. Thanks for sharing.

    Cheers,
    http://www.flowerbrackets.com/hashset-java/

    ReplyDelete